You are here

function table_element_validate_table in Table Element 7

An #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 'table_element_validate_table'
table_element_element_info in ./table_element.module
Implements hook_element_info().

File

./table_element.module, line 173
Provides a table element for Drupal 7.

Code

function table_element_validate_table(array $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 (empty($element['#value'])) {
    form_error($element, t('No item selected.'));
  }
}