function UpdateManagerUpdate::validateForm

Same name and namespace in other branches
  1. 9 core/modules/update/src/Form/UpdateManagerUpdate.php \Drupal\update\Form\UpdateManagerUpdate::validateForm()
  2. 8.9.x core/modules/update/src/Form/UpdateManagerUpdate.php \Drupal\update\Form\UpdateManagerUpdate::validateForm()
  3. 10 core/modules/update/src/Form/UpdateManagerUpdate.php \Drupal\update\Form\UpdateManagerUpdate::validateForm()

Overrides FormBase::validateForm

File

core/modules/update/src/Form/UpdateManagerUpdate.php, line 358

Class

UpdateManagerUpdate
Configure update settings for this site.

Namespace

Drupal\update\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    if (!$form_state->isValueEmpty('projects')) {
        $installed = array_filter($form_state->getValue('projects'));
    }
    if (!$form_state->isValueEmpty('uninstalled_projects')) {
        $uninstalled = array_filter($form_state->getValue('uninstalled_projects'));
    }
    if (empty($installed) && empty($uninstalled)) {
        $form_state->setErrorByName('projects', $this->t('You must select at least one project to update.'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.