You are here

function _element_epub_custom_chapter_size_validate in Epub 6

Validator helper for admin settings form.

Check chapter size field against a few rules and in case set form error messages.

Parameters

$element: An array containing form element structure.

&$form_state: State of the form containing data inserted by the user.

Return value

NULL.

1 string reference to '_element_epub_custom_chapter_size_validate'
epub_admin_settings in ./epub.admin.inc
Build and return the book settings form.

File

./epub.admin.inc, line 69
Admin page callbacks for the book module.

Code

function _element_epub_custom_chapter_size_validate($element, &$form_state) {
  $value = isset($form_state['values']['epub_custom_chapter_size']) ? $form_state['values']['epub_custom_chapter_size'] : NULL;
  if (!is_numeric($value)) {
    form_set_error('epub_custom_chapter_size', t('Please enter a number between 1 and 250'));
    return;
  }
  if ($value < 1) {
    form_set_error('epub_custom_chapter_size', t("Chapter size can' t be less than 1 kB"));
    return;
  }
  if ($value > 250) {
    form_set_error('epub_custom_chapter_size', t("Chapter size can' t exceed 250 kB"));
    return;
  }
}