Created
October 24, 2015 20:34
-
-
Save nevergone/23f0a50bee01acc34ed2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Form callback | |
*/ | |
function ajax_disable_test_form($form, &$form_state) { | |
$form['select'] = array( | |
'#type' => 'select', | |
'#required' => FALSE, | |
'#title' => t('Change me!'), | |
'#empty_option' => t('- Select -'), | |
'#options' => drupal_map_assoc(range(1, 3)), | |
'#prefix' => '<div id="select_box_wrapper">', | |
'#suffix' => '</div>', | |
); | |
$form['change'] = array( | |
'#type' => 'submit', | |
'#value' => t('Change!'), | |
'#ajax' => array( | |
'callback' => 'ajax_disable_test_form_submit_ajax', | |
'wrapper' => 'select_box_wrapper', | |
), | |
); | |
return $form; | |
} | |
/** | |
* Ajax callback | |
*/ | |
function ajax_disable_test_form_submit_ajax($form, $form_state) { | |
$form['select']['#title'] = t('Changed!'); // It's work! | |
$form['select']['#disabled'] = TRUE; // It's not work! | |
return $form['select']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.drupal.hu/forum/ajax-esemenyre-legordulo-kivalaszto-letiltasa/22861
http://drupal.stackexchange.com/questions/178599/ajax-event-and-disable-select-form-element