You are here

public function LockrAdvancedForm::buildForm in Lockr 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/LockrAdvancedForm.php \Drupal\lockr\Form\LockrAdvancedForm::buildForm()
  2. 8.2 src/Form/LockrAdvancedForm.php \Drupal\lockr\Form\LockrAdvancedForm::buildForm()
  3. 4.x src/Form/LockrAdvancedForm.php \Drupal\lockr\Form\LockrAdvancedForm::buildForm()

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/LockrAdvancedForm.php, line 77

Class

LockrAdvancedForm
Form handler for advanced Lockr settings.

Namespace

Drupal\lockr\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['fs'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Advanced'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  ];
  $config = $this->configFactory
    ->get('lockr.settings');
  $form['fs']['region'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Region'),
    '#default_value' => $config
      ->get('region'),
    '#empty_option' => $this
      ->t('- Nearest -'),
    '#options' => [
      'us' => 'US',
      'eu' => 'EU',
    ],
  ];
  $form['fs']['custom'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Set custom certificate location'),
    '#default_value' => $config
      ->get('custom', FALSE),
  ];
  $form['fs']['custom_cert'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Certificate path'),
    '#default_value' => $config
      ->get('cert_path'),
    '#states' => [
      'visible' => [
        ':input[name="custom"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['fs']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
  ];
  return $form;
}