function elements_table_value in Elements 7
Determines the value of a table form element.
Parameters
array $element: The form element whose value is being populated.
array|false $input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Return value
array The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.
1 string reference to 'elements_table_value'
- elements_element_info in ./
elements.module - Implements hook_element_info().
File
- ./
elements.module, line 362
Code
function elements_table_value(array $element, $input = FALSE) {
// If #multiple is FALSE, the regular default value of radio buttons is used.
if (!empty($element['#tableselect']) && !empty($element['#multiple'])) {
// Contrary to #type 'checkboxes', the default value of checkboxes in a
// table is built from the array keys (instead of array values) of the
// #default_value property.
// @todo D8: Remove this inconsistency.
if ($input === FALSE) {
$element += array(
'#default_value' => array(),
);
return drupal_map_assoc(array_keys(array_filter($element['#default_value'])));
}
else {
return is_array($input) ? drupal_map_assoc($input) : array();
}
}
}