You are here

function _juicebox_element_validate_config in Juicebox HTML5 Responsive Image Galleries 7

Form validation callback: validate Juicebox configuration options.

See also

_juicebox_common_form_elements()

1 string reference to '_juicebox_element_validate_config'
_juicebox_common_form_elements in ./juicebox.module
Helper to add common elements to Juicebox configuration forms.

File

./juicebox.module, line 829
Provides Drupal integration with the Juicebox library.

Code

function _juicebox_element_validate_config($element, &$form_state, $form) {

  // We are looking for input in the format of: optionName="optionValue".
  // The check here is not too strict, it is just meant to catch general
  // formatting issues.
  $custom_options = explode("\n", $element['#value']);
  foreach ($custom_options as $key => $option) {
    $option = trim($option);
    $line_number = $key + 1;
    if (!empty($option) && !preg_match('/^[A-Za-z0-9]+?="[^"]+?"$/u', $option)) {
      form_error($element, t('One of your manual configuration options appears to be formatted incorrectly. Please check line @line of this field and ensure that you are using the format <strong>optionName="optionValue"</strong> and that all spaces have been removed.', array(
        '@line' => $line_number,
      )));
    }
  }
}