You are here

public function Oauth2ClientPluginConfigForm::buildForm in OAuth2 Client 8.3

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/Oauth2ClientPluginConfigForm.php, line 71

Class

Oauth2ClientPluginConfigForm
Configure OAuth2 Client settings for this site.

Namespace

Drupal\oauth2_client\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['title'] = [
    '#type' => 'html_tag',
    '#tag' => 'h2',
    '#value' => $this->plugin
      ->getName(),
  ];
  $form['plugin'] = [];
  $subformState = SubformState::createForSubform($form['plugin'], $form, $form_state);
  $form['plugin'] = $this->plugin
    ->buildConfigurationForm($form['plugin'], $subformState);
  $form['plugin']['#tree'] = TRUE;
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save configuration'),
    '#button_type' => 'primary',
  ];
  $form['actions']['test'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save and request token'),
    '#submit' => [
      '::testToken',
    ],
    '#button_type' => 'secondary',
  ];
  $form['#description'] = $this
    ->t('<em>Save</em> will simply save this configuration. <em>Save and request token</em> will save this configuration and then request and store a token for future use.');

  // By default, render the form using system-config-form.html.twig.
  $form['#theme'] = 'system_config_form';
  return $form;
}