function UpdateManagerInstall::validateForm

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

Overrides FormBase::validateForm

File

core/modules/update/src/Form/UpdateManagerInstall.php, line 142

Class

UpdateManagerInstall
Configure update settings for this site.

Namespace

Drupal\update\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    $all_files = $this->getRequest()->files
        ->get('files', []);
    if ($this->moduleHandler
        ->moduleExists('file')) {
        if (!($form_state->getValue('project_url') xor !empty($all_files['project_upload']))) {
            $form_state->setErrorByName('project_url', $this->t('You must either provide a URL or upload an archive file.'));
        }
    }
    else {
        if (!$form_state->getValue('project_url')) {
            $form_state->setErrorByName('project_url', $this->t('You must provide a URL to install.'));
        }
    }
}

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