function form_type_tableselect_value

Determines the value for a tableselect form element.

Parameters

$element: The form element whose value is being populated.

$input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.

Return value

The data that will appear in $form_state['values'] for this element, or nothing to use the default.

Related topics

File

includes/form.inc, line 2444

Code

function form_type_tableselect_value($element, $input = FALSE) {
    // If $element['#multiple'] == FALSE, then radio buttons are displayed and
    // the default value handling is used.
    if (isset($element['#multiple']) && $element['#multiple']) {
        // Checkboxes are being displayed with the default value coming from the
        // keys of the #default_value property. This differs from the checkboxes
        // element which uses the array values.
        if ($input === FALSE) {
            $value = array();
            $element += array(
                '#default_value' => array(),
            );
            foreach ($element['#default_value'] as $key => $flag) {
                if ($flag) {
                    $value[$key] = $key;
                }
            }
            return $value;
        }
        else {
            return is_array($input) ? drupal_map_assoc($input) : array();
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.