function webform_expand_grid in Webform 6.3
Same name and namespace in other branches
- 7.4 components/grid.inc \webform_expand_grid()
- 7.3 components/grid.inc \webform_expand_grid()
A Form API #process function for Webform grid fields.
1 string reference to 'webform_expand_grid'
- _webform_render_grid in components/
grid.inc - Implements _webform_render_component().
File
- components/
grid.inc, line 178 - Webform module grid component.
Code
function webform_expand_grid($element) {
$options = $element['#grid_options'];
$questions = $element['#grid_questions'];
if (!empty($element['#optrand'])) {
_webform_shuffle_options($options);
}
if (!empty($element['#qrand'])) {
_webform_shuffle_options($questions);
}
foreach ($questions as $key => $question) {
if ($question != '') {
$element[$key] = array(
'#title' => $question,
'#required' => $element['#required'],
'#options' => $options,
'#type' => 'radios',
'#process' => array(
'expand_radios',
'webform_expand_select_ids',
),
// Webform handles validation manually.
'#validated' => TRUE,
'#webform_validated' => FALSE,
'#translatable' => array(
'title',
),
);
}
}
$value = isset($element['#default_value']) ? $element['#default_value'] : array();
foreach (element_children($element) as $key) {
if (isset($value[$key])) {
$element[$key]['#default_value'] = $value[$key] !== '' ? $value[$key] : NULL;
}
else {
$element[$key]['#default_value'] = NULL;
}
}
return $element;
}