You are here

function backstretch_element_validate_duration in Backstretch 7.2

Form element validation handler for elements that must be a duration.

2 string references to 'backstretch_element_validate_duration'
backstretch_context_reaction_backstretch::options_form in plugins/backstretch_context_reaction_backstretch.inc
backstretch_field_formatter_settings_form in ./backstretch.module
Implements hook_field_formatter_settings_form().

File

./backstretch.module, line 504
Main file for Backstretch Formatter module.

Code

function backstretch_element_validate_duration($element, &$form_state) {
  $value = $element['#value'];

  // A duration can be an integer or a string like 'slow' or 'fast'.
  if ($value !== '' && !is_numeric($value) && intval($value) == $value && $value >= 0) {
    form_error($element, t('%name must be an integer.', array(
      '%name' => $element['#title'],
    )));
  }
}