Determines the value of a table form element.
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.
array The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.
function form_type_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();
}
}
}