public function PardotSettingsForm::validateForm in Pardot Integration 8
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- src/
Form/ PardotSettingsForm.php, line 158
Class
- PardotSettingsForm
- Configure Pardot settings for this site.
Namespace
Drupal\Pardot\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// @Todo: replace custom validation with plugin validation, if core
// issue gets included: https://www.drupal.org/node/2843992.
// $this->path_condition->validateConfigurationForm($form, $form_state);
// Validates path conditions to ensure they have leading forward slash.
$paths = explode("\r\n", $form_state
->getValue('pages'));
foreach ($paths as $path) {
if (empty($path) || $path === '<front>' || strpos($path, '/') === 0) {
continue;
}
else {
$message = $this
->t('Paths require a leading forward slash when used with the Tracking Scope Pages setting.');
$form_state
->setErrorByName('pages', $message);
return;
}
}
parent::validateForm($form, $form_state);
}