You are here

public function KeyAddForm::buildForm in Key 8

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

File

src/Form/KeyAddForm.php, line 17

Class

KeyAddForm
Class KeyAddForm.

Namespace

Drupal\key\Form

Code

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

  // Only when the form is first built.
  if (!$form_state
    ->isRebuilding()) {

    // Set the key value data to NULL, since this is a new key.
    $form_state
      ->set('key_value', [
      'original' => NULL,
      'processed_original' => NULL,
      'obscured' => NULL,
      'current' => '',
    ]);
  }
  return parent::buildForm($form, $form_state);
}