You are here

function _textformatter_validate_class in Text list formatter 7

Same name and namespace in other branches
  1. 8.2 textformatter.module \_textformatter_validate_class()

Validate that a space-separated list of values are lowercase and appropriate for use as HTML classes.

See also

textformatter_field_formatter_settings_form()

1 string reference to '_textformatter_validate_class'
textformatter_field_formatter_settings_form in ./textformatter.module
Implements hook_field_formatter_Settings_form().

File

./textformatter.module, line 196
Provide a field formatter to render values as HTML or comma-separated lists.

Code

function _textformatter_validate_class($element, &$form_state) {
  $value = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
  $classes = explode(' ', $value);
  foreach ($classes as $class) {
    if ($class != drupal_html_class($class)) {
      form_error($element, t('List classes contain illegal characters; classes should be lowercase and may contain letters, numbers, and dashes.'));
      return;
    }
  }
}