Skip to content

Instantly share code, notes, and snippets.

@robballou
Created May 30, 2012 22:53
Show Gist options
  • Save robballou/2839427 to your computer and use it in GitHub Desktop.
Save robballou/2839427 to your computer and use it in GitHub Desktop.
<?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