You are here

public function Token::validateConfigurationForm in Commerce AutoSKU 8.2

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 CommerceAutoSkuGeneratorBase::validateConfigurationForm

File

src/Plugin/CommerceAutoSkuGenerator/Token.php, line 112

Class

Token
Provides the token commerce_autosku generator.

Namespace

Drupal\commerce_autosku\Plugin\CommerceAutoSkuGenerator

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValue($form['#parents']);
  $tokens = $this->token
    ->scan($values['pattern']);
  if (empty($tokens) && !empty($values['pattern'])) {
    $form_state
      ->setError($form['pattern'], 'At least one token from available tokens list required');
  }
}