I'm having trouble with something incredibly simple: When I select an element in a multiselect-form element, I want a textfield to become enabled. The problem I'm having is that Drupal never manages to get in the callback-function I specified.
Here I create my multiselect-element:
$form['foocat'] = array(
'#type' => 'fieldset',
'#title' => t('Manage subcategories'),
'#prefix' => '<div class="fieldset">',
'#suffix' => '</div>',
);
$form['foocat']['subcategories'] = array(
'#type' => 'select',
'#default_value' => '',
'#title' => $foocategory,
'#options' => $options,
'#ajax' => array(
'callback' => 'edit_displayname_callback',
'wrapper' => 'displayname',
),
'#attributes' => array('id' => 'foocats',),
'#prefix' => '<div class="formselect" id="selectmapcat">',
'#suffix' => '</div>',
'#size' => 9,
);
A little bit further in the code I create my textfield:
$form['foocat']['subcat_displayname'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $entity->foocategory,
'#size' => 25,
'#maxlength' => 31,
'#prefix' => '<div class="floater" id="displayname">',
'#suffix' => '</div>',
'#disabled' => TRUE,
);
if(!empty($form_state['subcategories'])) {
$form['foocat']['subcat_displayname']['#disabled'] = FALSE;
//Code for setting the textfield, dependent on what's been selected in the multiselect
}
And this is my callback function:
function edit_displayname_callback($form, &$form_state) {
watchdog("Test", "Testing callback..", array(), WATCHDOG_ALERT);
return $form['foocat']['subcat_displayname'];
}
The callback is never even called, and I have no idea why. I use AJAX in another part of the same form, and there it does work, so I'm guessing it's not a form problem.
Can anyone spot the problem?