You are here

public function BlockForm::validateForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::validateForm()
  2. 10 core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::validateForm()

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

core/modules/block/src/BlockForm.php, line 305

Class

BlockForm
Provides form for block instance forms.

Namespace

Drupal\block

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $form_state
    ->setValue('weight', (int) $form_state
    ->getValue('weight'));

  // The Block Entity form puts all block plugin form elements in the
  // settings form element, so just pass that to the block for validation.
  $this
    ->getPluginForm($this->entity
    ->getPlugin())
    ->validateConfigurationForm($form['settings'], SubformState::createForSubform($form['settings'], $form, $form_state));
  $this
    ->validateVisibility($form, $form_state);
}