You are here

public function DynamicFilterForm::validateForm in Feed Import 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/DynamicFilterForm.php, line 162
Contains \Drupal\feed_import\Form\DynamicFilterForm

Class

DynamicFilterForm

Namespace

Drupal\feed_import\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('func') && !preg_match('/^_[a-z0-9_]+$/i', $form_state
    ->getValue('func'))) {
    $form_state
      ->setError($form['func'], t('Name must start with underscore and can contain only alphanumeric chars or underscores.'));
    $form['add_new_func']['#ajax']['wrapper'] = 'func-container';
  }
}