You are here

public function SettingsForm::buildForm in Bootstrap Layout Builder 2.x

Same name and namespace in other branches
  1. 1.x src/Form/SettingsForm.php \Drupal\bootstrap_layout_builder\Form\SettingsForm::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 ConfigFormBase::buildForm

File

src/Form/SettingsForm.php, line 39

Class

SettingsForm
Configure Bootstrap Layout Builder settings.

Namespace

Drupal\bootstrap_layout_builder\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config(static::SETTINGS);
  $form['hide_section_settings'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Hide "Advanced Settings"'),
    '#default_value' => $config
      ->get('hide_section_settings'),
  ];
  $form['live_preview'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable live preview'),
    '#default_value' => $config
      ->get('live_preview'),
  ];
  $form['responsive'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable responsive'),
    '#default_value' => $config
      ->get('responsive'),
  ];
  $form['one_col_layout_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('One col layout class'),
    '#maxlength' => 20,
    '#default_value' => $config
      ->get('one_col_layout_class') ?: 'col-12',
    '#description' => $this
      ->t('eg: col-12.'),
    '#required' => TRUE,
  ];
  return parent::buildForm($form, $form_state);
}