Hi everyone,
In a standard webpage, I am trying to populate field 2 (animal_list) based on the initial selection in field 1 (animal_type). So if a user selects Wild from the dropdown (field 1), a list of wild animals appears in the animal_list field (field 2). If however they select Pets, then a list of pets appears in the same animal_list field. I can do this in an Ultimate Member form, but I cannot seem to achieve the same result in a standard webpage that I wish to use for registration.
The problem I am having is with the duplicate animal_list field. When I use this the animal_list field does not populate as expected. I just want to filter the animal_list field based on the animal_type selection.
Not sure what to do from here. Can anyone help me with this?
<?php
$fields[] = new PMProRH_Field(
'animal_type', // input name, will also be used as meta key
'select', // type of field
array(
'required' => true, // make this field required
'profile' => false, // do not only show in profile for admins
'levels' => array(7), // only levels 11 and 12 should have the type field
'label' => 'What type of animal are you registering?', // custom field label
'options' => array( // <option> elements for select field
'' => 'Please select animal type', // blank option - cannot be selected if this field is required
'Wild' => 'Wild', // <option value="3</option>
'Pets' => 'Pets', // <option value="3</option>
)
)
);
$fields[] = new PMProRH_Field(
"animal_list", // input name, will also be used as meta key
"select", // type of field
array(
"options" => array( // <option> elements for select field
'' => 'Please select animal type', // blank option - cannot be selected if this field is required
'Tiger'=>'Tiger',//<option value="1</option>
'Lion'=>'Lion',//<option value="1</option>
'Eagle'=>'Eagle',//<option value="1</option>
),
"label" => "Wild Animal Types",
"levels" => array(7),
"profile" => true,
"required" => true,
"depends" => array(
array(
"id" => "animal_type", //depends on this field
"value" => "Wild" //if selected show this field
)
)
)
);
$fields[] = new PMProRH_Field(
"animal_list", // input name, will also be used as meta key
"select", // type of field
array(
"options" => array( // <option> elements for select field
'' => 'Please select animal type', // blank option - cannot be selected if this field is required
'Cat'=>'Cat',//<option value="1</option>
'Dog'=>'Dog',//<option value="1</option>
'Budgie'=>'Budgie',//<option value="1</option>
),
"label" => "Pet Types",
"levels" => array(7),
"profile" => true,
"required" => true,
"depends" => array(
array(
"id" => "animal_type", //depends on this field
"value" => "Pets" //if selected show this field
)
)
)
);- This topic was modified 14 hours, 55 minutes ago by .
- This topic was modified 14 hours, 52 minutes ago by .
- This topic was modified 14 hours, 51 minutes ago by .
