public static function GoogleAnalyticsAdminSettingsForm::validateCreateFieldValues in Google Analytics 8.2
The #element_validate callback for create only fields.
Parameters
array $element: An associative array containing the properties and children of the generic form element.
\Drupal\Core\Form\FormStateInterface $form_state: The $form_state array for the form this element belongs to.
See also
form_process_pattern()
File
- src/
Form/ GoogleAnalyticsAdminSettingsForm.php, line 882
Class
- GoogleAnalyticsAdminSettingsForm
- Configure Google_Analytics settings for this site.
Namespace
Drupal\google_analytics\FormCode
public static function validateCreateFieldValues(array $element, FormStateInterface $form_state) {
$values = static::extractCreateFieldValues($element['#value']);
if (!is_array($values)) {
$form_state
->setError($element, t('The %element-title field contains invalid input.', [
'%element-title' => $element['#title'],
]));
}
else {
// Check that name and value are valid for the field type.
foreach ($values as $name => $value) {
if ($error = static::validateCreateFieldName($name)) {
$form_state
->setError($element, $error);
break;
}
if ($error = static::validateCreateFieldValue($value)) {
$form_state
->setError($element, $error);
break;
}
}
$form_state
->setValueForElement($element, $values);
}
}