By saitanay on
I have a form, which is a view with exposed filters.
In that 2 of the exposed filters are taxonpmy term references. Based on the selection of the first, need to change the options in the second select.
since the form is already built,. started with a form alter, with
The first select :
$options_first = _get_states_for_select();
$selected = isset($form_state['input']['field_tpcc_lice_locstate_tid']) ? $form_state['input']['field_tpcc_lice_locstate_tid'] : key($options_first);
$form['field_tpcc_lice_locstate_tid']['#options'] = $options_first;
$form['field_tpcc_lice_locstate_tid']['#default-value'] = $selected;
$form['field_tpcc_lice_locstate_tid']['#ajax'] = array(
'callback' => 'select_callback',
'wrapper' => 'type_replace',
);Then the second select
$form['field_tpcc_lice_lictype_tid']['#prefix'] = '<div id="type_replace">';
$form['field_tpcc_lice_lictype_tid']['#suffix'] = '</div>';
$form['field_tpcc_lice_lictype_tid']['#options'] = _get_lic_type_options($selected);
$form['field_tpcc_lice_lictype_tid']['#default-value'] = isset($form_state['input']['field_tpcc_lice_lictype_tid']) ? $form_state['input']['field_tpcc_lice_lictype_tid'] : '';The call back simply returns the second select again:
function select_callback($form, $form_state) {
return $form['field_tpcc_lice_lictype_tid'];
}The helper functions return assocative arrays (these are fine).
function _automobile_get_manufacturer_dropdown_options() {
//returns an assc array
}function _get_lic_type_options($key = '') {
//returns an assoc array
}When first select is clicked, an ajax call is initialised, but geting an error in the popup(overlay)
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /d1/?q=system/ajax
StatusText: OK
ResponseText: Do u see sth wrong in above code?
Comments
A problem can be that you
A problem can be that you want to get the submitted values from
But they are in
But I'm not sure this is the reason of the error.
Regards,
David
may sound weird,. but a dsm
may sound weird,. but a dsm showed that $form_state has ['values'] and no ['input'],.
dint bother why,. ;-)
teh ajax post request as seen
teh ajax post request as seen from firebug
Response is blank