Created
May 30, 2012 22:53
-
-
Save robballou/2839427 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
function my_module_form($form, &$form_state) { | |
$form['sample_field'] = array( | |
'#type' => 'checkboxes' | |
'#title' => 'Sample', | |
'#options' => array('test' => 'Test') | |
); | |
$form['select_box'] = array( | |
'#type' => 'select', | |
'#title' => 'Select a value', | |
'#options' => array('value1' => 'value 1', 'value2' => 'value 2'), | |
'#ajax' => array( | |
'wrapper' => 'wrapper_id', | |
'callback' => 'my_module_ajax_callback' | |
) | |
); | |
$form['wrapper'] = array( | |
'#markup' => '<div id="wrapper_id"></div>' | |
); | |
return $form; | |
} | |
function my_module_ajax_callback($form, $form_state) { | |
// this returns a field, but no checkboxes | |
// if I switch to select, it works | |
return array( | |
'#type' => 'checkboxes', | |
'#title' => 'Checkboxes', | |
'#options' => array('asdf' => 'ASDF') | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment