You are here

public function HidePreviewConfigForm::validateForm in Hide Preview Button 8

Validates the users's input.

Overrides FormBase::validateForm

File

src/Form/HidePreviewConfigForm.php, line 64

Class

HidePreviewConfigForm
This class renders and manages the configuration form of the module.

Namespace

Drupal\hide_preview\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $formNames = $form_state
    ->getValue('form_names');
  $formNames = $this
    ->multiline2Array($formNames);
  foreach ($formNames as &$name) {
    $name = trim($name);
    preg_match('/[^\\w]+/', $name, $matches);
    if (count($matches)) {
      if (@preg_match($name, NULL) === FALSE) {
        $form_state
          ->setErrorByName('form_names', $this
          ->t('Form name "%name" contains non wordy characters and is
            not a regexp.', [
          '%name' => $name,
        ]));
      }
    }
  }
  parent::validateForm($form, $form_state);
}