Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By marwen.blel on
hello iam trying to user ajax callback in my method value_form of my handler and doesnt work, here is my code
/**
* Provide a simple select list for equality
*/
function value_form(&$form, &$form_state) {
$countries = _prepare_countries_list();
$selected_country = isset($form_state['values']['value']['country'])?$form_state['values']['value']['country']:key($countries);
$values = array(
'country' => array(
'#type' => 'select',
'#title' => t('Country'),
'#options' =>$countries,
'#ajax' => array(
'callback' => 'country_state_dependent_dropdown_callback',
'wrapper' => 'dropdown-states',
),
),
'state' => array(
'#type' => 'select',
'#title' => t('State'),
/*'#options' =>array(
'All' => t('--Any--'),
'tunis' => t('Tunis'),
'marseille' => t('Marseille'),
),*/
'#prefix' => '<div id="dropdown-states">',
'#suffix' => '</div>',
'#options' => _country_state_get_second_dropdown_options('france'),
),
);
$form['value'] = $values;
return $form;
}
function country_state_dependent_dropdown_callback(&$form, &$form_state) {
return $form['value']['state'];
}
any solution to fix that problem