function table_element_table_value in Table Element 7
Determines the value of a table form element.
Parameters
array $element: The form element whose value is being populated.
array|bool $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 'table_element_table_value'
- table_element_element_info in ./
table_element.module - Implements hook_element_info().
File
- ./
table_element.module, line 50 - Provides a table element for Drupal 7.
Code
function table_element_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.
if (FALSE === $input) {
$element += array(
'#default_value' => array(),
);
return drupal_map_assoc(array_keys(array_filter($element['#default_value'])));
}
elseif (is_array($input)) {
return drupal_map_assoc($input);
}
}
return array();
}