function webform_optionsmarkup_expand_checkboxes in Webform Options Markup 7.2
Same name and namespace in other branches
- 7 components/webform_optionsmarkup.inc \webform_optionsmarkup_expand_checkboxes()
Drupal 6 hack that properly *renders* checkboxes in multistep forms.
This is different than the value hack needed in Drupal 5, which is no longer needed.
1 string reference to 'webform_optionsmarkup_expand_checkboxes'
- _webform_render_optionsmarkup in components/
webform_optionsmarkup.inc - Implements _webform_render_component().
File
- components/
webform_optionsmarkup.inc, line 295 - Webform component that allows markup in checkbox and radio options.
Code
function webform_optionsmarkup_expand_checkboxes($element) {
// Elements that have a value set are already in the form structure cause
// them not to be written when the expand_checkboxes function is called.
$default_value = array();
foreach (element_children($element) as $key) {
if (isset($element[$key]['#default_value'])) {
$default_value[$key] = $element[$key]['#default_value'];
unset($element[$key]);
}
}
$element = webform_optionsmarkup_process_optionsmarkup_checkboxes($element);
// Escape the values of checkboxes.
foreach (element_children($element) as $key) {
$element[$key]['#return_value'] = check_plain($element[$key]['#return_value']);
$element[$key]['#name'] = $element['#name'] . '[' . $element[$key]['#return_value'] . ']';
}
foreach ($default_value as $key => $val) {
$element[$key]['#default_value'] = $val;
}
return $element;
}