You are here

function entityreference_multiple_number_validate in Entity reference multiple display 7

Form element validation handler for positive integer elements.

1 string reference to 'entityreference_multiple_number_validate'
entityreference_multiple_field_formatter_settings_form in ./entityreference_multiple.module
Implements hook_field_formatter_settings_form().

File

./entityreference_multiple.module, line 134
Extend entity reference formatter with an option to separate elements display with specific view_modes.

Code

function entityreference_multiple_number_validate($element, &$form_state, $form) {
  $value = $element['#value'];
  if ($value != '#' && (!is_numeric($value) || intval($value) != $value || $value <= 0)) {
    form_error($element, t('%name must be a positive integer.', array(
      '%name' => $element['#title'],
    )));
  }
}