You are here

public function LockrCSRForm::buildForm in Lockr 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 FormInterface::buildForm

File

src/Form/LockrCSRForm.php, line 60

Class

LockrCSRForm

Namespace

Drupal\lockr\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $dn = $this->state
    ->get('lockr.cert_dn', []);
  $form['description'] = [
    '#prefix' => '<p>',
    '#suffix' => '</p>',
  ];
  $form['country'] = [
    '#type' => 'textfield',
    '#title' => 'Country',
    '#default' => isset($dn['countryName']) ? $dn['countryName'] : NULL,
    '#maxlength' => 2,
    '#attributes' => [
      'placeholder' => [
        'US',
      ],
    ],
    '#required' => TRUE,
  ];
  $form['state'] = [
    '#type' => 'textfield',
    '#title' => 'State or Province',
    '#default' => isset($dn['stateOrProvinceName']) ? $dn['stateOrProvinceName'] : NULL,
    '#attributes' => [
      'placeholder' => [
        'Washington',
      ],
    ],
    '#required' => TRUE,
  ];
  $form['city'] = [
    '#type' => 'textfield',
    '#title' => 'Locality',
    '#default' => isset($dn['localityName']) ? $dn['localityName'] : NULL,
    '#attributes' => [
      'placeholder' => [
        'Seattle',
      ],
    ],
    '#required' => TRUE,
  ];
  $form['org'] = [
    '#type' => 'textfield',
    '#title' => 'Organization',
    '#default' => isset($dn['organizationName']) ? $dn['organizationName'] : NULL,
    '#attributes' => [
      'placeholder' => [
        'ACME, Inc.',
      ],
    ],
    '#required' => TRUE,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => 'Create Certificate',
  ];
  return $form;
}