You are here

public function FindReplaceRegex::validateConfigurationForm in Tamper 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides TamperBase::validateConfigurationForm

File

src/Plugin/Tamper/FindReplaceRegex.php, line 69

Class

FindReplaceRegex
Plugin implementation of the Find replace REGEX plugin.

Namespace

Drupal\tamper\Plugin\Tamper

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

  // Test the regex.
  $test = @preg_replace($form_state
    ->getValue(self::SETTING_FIND), '', 'asdfsadf');
  if ($test === NULL) {
    $form_state
      ->setErrorByName(self::SETTING_FIND, $this
      ->t('Invalid regular expression.'));
  }
}