function _google_tag_validate_listed_classes in GoogleTagManager 7.2
Same name and namespace in other branches
- 7 includes/variable.inc \_google_tag_validate_listed_classes()
Element validation handler for google_tag_listed_classes.
1 string reference to '_google_tag_validate_listed_classes'
- _google_tag_variable_info_advanced in includes/
variable.inc - Implements hook_variable_info().
File
- includes/
variable.inc, line 540 - Contains the variable definitions.
Code
function _google_tag_validate_listed_classes($variable, $options, $element, $form, &$form_state) {
if (!drupal_array_get_nested_value($form_state['values'], $element['#parents'])) {
return;
}
$keys = array(
'whitelist_classes',
'blacklist_classes',
);
$variables = isset($form['#variable_edit_form']) ? $form['#variable_edit_form'] : array();
$items = array_diff($keys, $variables);
if (!empty($items)) {
// Need both variables on form to validate.
form_set_error('include_classes', t('To validate listed classes, include the whitelist and blacklist variables in the realm variables.'));
return;
}
$empty = TRUE;
foreach ($keys as $key) {
array_pop($element['#parents']);
$element['#parents'][] = $key;
$classes = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
google_tag_text_clean($classes);
$empty &= empty($classes);
}
if ($empty) {
form_set_error('include_classes', t('Enter listed classes in at least one field, or uncheck the box.'));
form_set_error('whitelist_classes', '');
form_set_error('blacklist_classes', '');
}
}