You are here

public function OpmlFeedAdd::validateForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/aggregator/src/Form/OpmlFeedAdd.php \Drupal\aggregator\Form\OpmlFeedAdd::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/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.'));
  }
}