You are here

public function Oauth2ClientForm::buildForm in Simple OAuth (OAuth2) & OpenID Connect 8.2

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 EntityForm::buildForm

File

src/Entity/Form/Oauth2ClientForm.php, line 20

Class

Oauth2ClientForm
Form controller for Client edit forms.

Namespace

Drupal\simple_oauth\Entity\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  /* @var $entity \Drupal\simple_oauth\Entity\Oauth2ClientInterface */
  $form = parent::buildForm($form, $form_state);
  $entity = $this->entity;
  $form['langcode'] = array(
    '#title' => $this
      ->t('Language'),
    '#type' => 'language_select',
    '#default_value' => $entity
      ->getUntranslated()
      ->language()
      ->getId(),
    '#languages' => Language::STATE_ALL,
  );

  // Remove automatic roles.
  unset($form['roles']['widget']['#options'][RoleInterface::ANONYMOUS_ID]);
  unset($form['roles']['widget']['#options'][RoleInterface::AUTHENTICATED_ID]);
  $description = $this
    ->t('Use this field to create a hash of the secret key. This module will never store your client key, only a hash of it. Current hash: "%hash".', [
    '%hash' => $entity
      ->getSecret(),
  ]);
  $form['new_secret'] = [
    '#type' => 'password',
    '#title' => $this
      ->t('New Secret'),
    '#description' => $description,
  ];
  return $form;
}