You are here

public function RemoteForm::validateForm in Entity Share 8.3

Same name and namespace in other branches
  1. 8 modules/entity_share_client/src/Form/RemoteForm.php \Drupal\entity_share_client\Form\RemoteForm::validateForm()
  2. 8.2 modules/entity_share_client/src/Form/RemoteForm.php \Drupal\entity_share_client\Form\RemoteForm::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

modules/entity_share_client/src/Form/RemoteForm.php, line 89

Class

RemoteForm
Entity form of the remote entity.

Namespace

Drupal\entity_share_client\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {

  // Validate URL.
  if (!UrlHelper::isValid($form_state
    ->getValue('url'), TRUE)) {
    $form_state
      ->setError($form['url'], $this
      ->t('Invalid URL.'));
  }
  $selectedPlugin = $this
    ->getSelectedPlugin($form, $form_state);
  if ($selectedPlugin instanceof PluginFormInterface) {
    $subformState = SubformState::createForSubform($form['auth']['data'], $form, $form_state);
    $selectedPlugin
      ->validateConfigurationForm($form['auth']['data'], $subformState);
  }
}