You are here

public function SingleUserRoleConfigForm::buildForm in Single User Role 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/SingleUserRoleConfigForm.php, line 49

Class

SingleUserRoleConfigForm
Single User Role configuration settings.

Namespace

Drupal\single_user_role\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['single_user_role_field_type'] = [
    '#title' => t('Field type'),
    '#description' => t('Set type of field to use for user role selection.'),
    '#type' => 'select',
    '#default_value' => \Drupal::config('single_user_role.settings')
      ->get('single_user_role_field_type'),
    '#options' => [
      'select' => t('Select field'),
      'radios' => t('Radio field'),
    ],
  ];
  $form['single_user_role_field_desc'] = [
    '#title' => 'Role field helptext',
    '#type' => 'textarea',
    '#description' => t('This text is displayed at user role field.'),
    '#default_value' => \Drupal::config('single_user_role.settings')
      ->get('single_user_role_field_desc'),
    '#cols' => 40,
    '#rows' => 4,
  ];
  return parent::buildForm($form, $form_state);
}