As given in the code below, I tried enabling select list $form['answer']['answer1'] through AJAX callback, textbox is getting populated with value, where as the dropdownlist is not getting enabled. Any help?
function mymodule_search_block_form($form, &$form_state) {
$options = array();
$options['key1'] = t('value1');
$options['key2'] = t('value2');
$options['key3'] = t('value3');
$options['key4'] = t('value4');
$form['profiles'] = array(
'#type' => 'select',
'#title' => 'Profiles',
'#options' => $options,
'#ajax' => array(
'callback' => 'ajax_select_callback',
'wrapper' => 'profile-wrapper',
'event' => 'change',
),
);
$form['answer']['profile_name'] = array(
'#prefix' => '<div id="profile-wrapper">',
'#type' => 'textfield',
'#title' => 'Profile Name1',
);
$form['answer']['profile_name2'] = array(
'#type' => 'textfield',
'#title' => 'Profile Name2',
);
$form['answer']['answer1'] = array(
'#type' => 'select',
'#disabled' => 1,
'#title' => 'Profiles',
'#options' => $options,
'#suffix' => '</div></br>',
);
return $form;
}
function ajax_select_callback($form, $form_state) {
$form['answer']['profile_name']['#value'] = 'Profile 1';
$form['answer']['profile_name2']['#value'] = 'Profile 2';
$form['answer']['answer1']['#disabled'] = 0;
return $form['answer'];
}