You are here

public function RegcodeAdminSettingsForm::buildForm in Registration codes 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 ConfigFormBase::buildForm

File

src/Form/RegcodeAdminSettingsForm.php, line 30

Class

RegcodeAdminSettingsForm
Configuration settings for the registration codes module.

Namespace

Drupal\regcode\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $regcode_config = $this
    ->config('regcode.settings');
  $form = [];
  $form['regcode_forms'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Registration form field'),
  ];
  $form['regcode_forms']['regcode_field_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Field label'),
    '#description' => $this
      ->t('The label of the registration code textfield'),
    '#required' => TRUE,
    '#default_value' => $regcode_config
      ->get('regcode_field_title'),
  ];
  $form['regcode_forms']['regcode_field_description'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Field description'),
    '#description' => $this
      ->t('The description under the registration code textfield'),
    '#rows' => 2,
    '#default_value' => $regcode_config
      ->get('regcode_field_description'),
  ];
  $form['regcode_forms']['regcode_optional'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Make registration code optional'),
    '#default_value' => $regcode_config
      ->get('regcode_optional'),
    '#description' => $this
      ->t('If checked, users can register without a registration code.'),
  ];
  return parent::buildForm($form, $form_state);
}