You are here

public function OpenIDConnectSettingsForm::validateForm in OpenID Connect / OAuth client 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/OpenIDConnectSettingsForm.php, line 238

Class

OpenIDConnectSettingsForm
Provides the OpenID Connect settings form.

Namespace

Drupal\openid_connect\Form

Code

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

  // Get clients' enabled status.
  $clients_enabled = $form_state
    ->getValue('clients_enabled');

  // Get client plugins.
  $clients = $this
    ->getClients();

  // Trigger validation for enabled clients.
  foreach ($clients_enabled as $plugin_id => $status) {

    // Whether the client is not enabled.
    if (!(bool) $status) {
      continue;
    }

    // Get subform and subform state.
    $subform = $form['clients'][$plugin_id]['settings'];
    $subform_state = SubformState::createForSubform($subform, $form, $form_state);

    // Let the plugin validate its form.
    $clients[$plugin_id]
      ->validateConfigurationForm($subform, $subform_state);
  }
}