You are here

function juicebox_element_validate_config in Juicebox HTML5 Responsive Image Galleries 7.2

Same name and namespace in other branches
  1. 8.3 juicebox.module \juicebox_element_validate_config()
  2. 8.2 juicebox.module \juicebox_element_validate_config()

Form validation callback: validate Juicebox configuration options.

1 string reference to 'juicebox_element_validate_config'
JuiceboxGalleryDrupal::confBaseForm in includes/JuiceboxGalleryDrupal.inc
Get common elements for Juicebox configuration forms.

File

./juicebox.module, line 434
Provides Drupal integration with the Juicebox library. This file contains the relevant Drupal hook implementations and callbacks.

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,
      )));
    }
  }
}