I need to add some AJAX functionality to a node form. Using hook_form_alter I'm overriding form elements. In this particular case I need to add a callback on the 'language' element provided by the translation module (Core, Content Translation).
However, when selecting a different option in the 'language' listbox, the page refreshes. What could trigger this behaviour?
This is the code I'm using:
function foo_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'bar_node_form') {
$form['#prefix'] = '<div id="bar-form-wrapper">';
$form['#suffix'] = '</div>';
$form['language']['#ajax'] = array(
'callback' => 'bar_form_callback',
'wrapper' => 'bar-form-wrapper',
);
if (isset($form_state['values'])) {
drupal_set_message('ajax callback');
}
}
}
function bar_form_callback($form, $form_state) {
return $form;
}