You are here

function elements_table_validate in Elements 7

#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 'elements_table_validate'
elements_element_info in ./elements.module
Implements hook_element_info().

File

./elements.module, line 481

Code

function elements_table_validate($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.'));
  }
}