You are here

public function AdminSettings::validateForm in Doubleclick for Publishers (DFP) 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/AdminSettings.php, line 199
Contains \Drupal\dfp\Form\AdminSettings.

Class

AdminSettings
Defines a form that configures DFP global settings.

Namespace

Drupal\dfp\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('click_url') && $form_state
    ->getValue('async_rendering')) {
    $form_state
      ->setErrorByName('click_url', $this
      ->t('Setting a click URL does not work with async rendering.'));
  }
  if (preg_match(TagInterface::ADUNIT_PATTERN_VALIDATION_REGEX, $form_state
    ->getValue('adunit_pattern'))) {
    $form_state
      ->setErrorByName('adunit_pattern', $this
      ->t('Ad Unit Patterns can only include letters, numbers, hyphens, dashes, periods, slashes and tokens.'));
  }
}