function _google_tag_validate_environment_id in GoogleTagManager 7.2
Same name and namespace in other branches
- 7 includes/variable.inc \_google_tag_validate_environment_id()
Element validation handler for google_tag_environment_id.
1 string reference to '_google_tag_validate_environment_id'
- _google_tag_variable_info_advanced in includes/
variable.inc - Implements hook_variable_info().
File
- includes/
variable.inc, line 509 - Contains the variable definitions.
Code
function _google_tag_validate_environment_id($variable, $options, $element, $form, &$form_state) {
// @todo This will not prevent checking 'include_environment' on an individual
// variable edit form and never setting the 'environment_id'.
$parents = $element['#parents'];
array_pop($parents);
$parents[] = 'include_environment';
$include_environment = drupal_array_get_nested_value($form_state['values'], $parents);
$value = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
$value = trim($value);
$value = str_replace(array(
'–',
'—',
'−',
), '-', $value);
drupal_array_set_nested_value($form_state['values'], $element['#parents'], $value);
if ($include_environment && !preg_match('/^env-\\d{1,}$/', $value)) {
return t('A valid environment ID is case sensitive and formatted like env-x.');
}
}