public function AuthorizationProfileForm::validateForm in Authorization 8
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
- src/Form/ AuthorizationProfileForm.php, line 567 
Class
- AuthorizationProfileForm
- Authorization profile form.
Namespace
Drupal\authorization\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) : void {
  parent::validateForm($form, $form_state);
  $authorization_profile = $this
    ->getEntity();
  // Only when the profile is new. Afterward we can't change provider.
  if ($authorization_profile
    ->getProviderId() !== $form_state
    ->getValues()['provider']) {
    $input = $form_state
      ->getUserInput();
    $input['provider_config'] = [];
    $form_state
      ->set('input', $input);
  }
  elseif ($form['provider_config']['#type'] === 'details' && $authorization_profile
    ->hasValidProvider()) {
    $provider_form_state = new SubFormState($form_state, [
      'provider_config',
    ]);
    $authorization_profile
      ->getProvider()
      ->validateConfigurationForm($form['provider_config'], $provider_form_state);
  }
  // Only when the profile is new. Afterward we can't change consumer.
  if ($authorization_profile
    ->getConsumerId() !== $form_state
    ->getValues()['consumer']) {
    $input = $form_state
      ->getUserInput();
    $input['consumer_config'] = [];
    $form_state
      ->set('input', $input);
  }
  elseif ($form['consumer_config']['#type'] === 'details' && $authorization_profile
    ->hasValidConsumer()) {
    $consumer_form_state = new SubFormState($form_state, [
      'consumer_config',
    ]);
    $authorization_profile
      ->getConsumer()
      ->validateConfigurationForm($form['consumer_config'], $consumer_form_state);
  }
  if ($form_state
    ->getValue('mappings')) {
    $mappings_form_state = new SubFormState($form_state, [
      'mappings',
    ]);
    $authorization_profile
      ->getConsumer()
      ->validateRowForm($form['mappings'], $mappings_form_state);
    $authorization_profile
      ->getProvider()
      ->validateRowForm($form['mappings'], $mappings_form_state);
  }
}