I know there are lots of tutorials on loads of sites (I have read most of them in the last few hours) but I still can not get the following code to work. Can anyone see what I am doing wrong?
The second select box does not update when I change a value in the first one and I don't get the blue spinning ajax circle next to the first select box when I make a change.
$form['age_range'] = array(
'#type'=>'select',
'#title'=>'Age Range',
'#options'=>$age_ranges,
'#ajax'=>array(
'event'=>'change',
'callback'=>'childcare_observations_ajax_set_eyfs_category_list',
'wrapper'=>'eyfs_category_wrapper',
'method'=>'replace',
)
);
$form['eyfs_category_wrapper'] = array('#prefix'=>'<div class="eyfs_category_wrapper">','#suffix'=>'</div>');
$form['eyfs_category_wrapper']['eyfs_category'] = array(
'#type'=>'select',
'#title'=>'EYFS Category',
'#options'=>array(1=>'one',2=>'Two'),
);
return $form;
}
function childcare_observations_ajax_set_eyfs_category_list($form,&$form_state){
$eyfs_category_options = array();
$eyfs_category_options[0] = "We just changed the list values";
$eyfs_category_options[1] = "We also added a second option";
$form['eyfs_category_wrapper']['eyfs_category'] = array(
'#type'=>'select',
'#title'=>'EYFS Category',
'#options'=>$eyfs_category_options,
);
return $form['eyfs_category_wrapper'];
}