You are here

function form_validate_table in Clock 7.2

#element_validate callback for #type 'table'.

Parameters

array $element: An associative array containing the properties and children of the table element.

array $form_state: The current state of the form.

1 string reference to 'form_validate_table'
clock_element_info in ./clock.module
Implements hook_element_info().

File

./clock.table.inc, line 151
Backports the 'table' form element from Drupal 7

Code

function form_validate_table($element, &$form_state) {

  // Skip this validation if the button to submit the form does not require
  // selected table row data.
  if (empty($form_state['triggering_element']['#tableselect'])) {
    return;
  }
  if ($element['#multiple']) {
    if (!is_array($element['#value']) || !count(array_filter($element['#value']))) {
      form_error($element, t('No items selected.'));
    }
  }
  elseif (!isset($element['#value']) || $element['#value'] === '') {
    form_error($element, t('No item selected.'));
  }
}