You are here

public function NumericBase::validateConfigurationForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/NumericBase.php \Drupal\webform\Plugin\WebformElement\NumericBase::validateConfigurationForm()

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

File

src/Plugin/WebformElement/NumericBase.php, line 96

Class

NumericBase
Provides a base 'numeric' class.

Namespace

Drupal\webform\Plugin\WebformElement

Code

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

  // Validate min/max value.
  $min = $form_state
    ->getValue('min');
  $max = $form_state
    ->getValue('max');
  if ($min === '' || !isset($min) || ($max === '' || !isset($max))) {
    return;
  }
  if ($min >= $max) {
    $form_state
      ->setErrorByName('min', $this
      ->t('Minimum value can not exceed the maximum value.'));
  }
}