function OpmlFeedAdd::validateForm

Same name in other branches
  1. 9 core/modules/aggregator/src/Form/OpmlFeedAdd.php \Drupal\aggregator\Form\OpmlFeedAdd::validateForm()

Overrides FormBase::validateForm

File

core/modules/aggregator/src/Form/OpmlFeedAdd.php, line 103

Class

OpmlFeedAdd
Imports feeds from OPML.

Namespace

Drupal\aggregator\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    // If both fields are empty or filled, cancel.
    $all_files = $this->getRequest()->files
        ->get('files', []);
    if ($form_state->isValueEmpty('remote') == empty($all_files['upload'])) {
        $form_state->setErrorByName('remote', $this->t('<em>Either</em> upload a file or enter a URL.'));
    }
}

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