You are here

public function LayoutBuilderModalSettingsForm::validateForm in Layout Builder Modal 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/LayoutBuilderModalSettingsForm.php, line 86

Class

LayoutBuilderModalSettingsForm
Provides the layout builder modal configuration form.

Namespace

Drupal\layout_builder_modal\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $height = $form_state
    ->getValue('modal_height');
  if ((!is_numeric($height) || $height < 1) && $height !== 'auto') {
    $form_state
      ->setErrorByName('modal_height', $this
      ->t('Height must be a positive number or "auto".'));
  }
}