function Table::valueCallback
Overrides FormElementBase::valueCallback
1 method overrides Table::valueCallback()
- Tableselect::valueCallback in core/
lib/ Drupal/ Core/ Render/ Element/ Tableselect.php  - Determines how user input is mapped to an element's #value property.
 
File
- 
              core/
lib/ Drupal/ Core/ Render/ Element/ Table.php, line 153  
Class
- Table
 - Provides a render element for a table.
 
Namespace
Drupal\Core\Render\ElementCode
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
  // 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 += [
        '#default_value' => [],
      ];
      $value = array_keys(array_filter($element['#default_value']));
      return array_combine($value, $value);
    }
    else {
      return is_array($input) ? array_combine($input, $input) : [];
    }
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.