You are here

public function EntityUpdateExec::validateForm in Entity Update 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/EntityUpdateExec.php \Drupal\entity_update\Form\EntityUpdateExec::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

src/Form/EntityUpdateExec.php, line 159

Class

EntityUpdateExec
Class CheckEntityUpdate.

Namespace

Drupal\entity_update\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $list = EntityUpdate::getEntityTypesToUpdate();
  $action = $form_state
    ->getValue('action');
  $actions = [
    'rescue',
    'clean',
  ];
  if (!in_array($action, $actions) && empty($list)) {
    $form_state
      ->setErrorByName('about', $this
      ->t("Nothing to update. All entities are up to date."));
  }
  elseif (!$form_state
    ->getValue('confirm')) {
    $form_state
      ->setErrorByName('confirm', $this
      ->t("If you want to execute, please check the checkbox."));
  }
}