You are here

public function DashboardFormBase::buildForm in Draggable dashboard 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 FormInterface::buildForm

1 call to DashboardFormBase::buildForm()
DashboardEditForm::buildForm in src/Form/DashboardEditForm.php
Form constructor.
2 methods override DashboardFormBase::buildForm()
DashboardEditForm::buildForm in src/Form/DashboardEditForm.php
Form constructor.
DashboardManageForm::buildForm in src/Form/DashboardManageForm.php
Form constructor.

File

src/Form/DashboardFormBase.php, line 77

Class

DashboardFormBase
Provides a base class for draggable dashboard add/edit forms.

Namespace

Drupal\draggable_dashboard\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $did = NULL) {
  $this->dashboard = $this
    ->buildDashboard($did);
  $form['title'] = [
    '#title' => $this
      ->t('Title'),
    '#type' => 'textfield',
    '#size' => 48,
    '#maxlength' => 255,
    '#default_value' => $this->dashboard
      ->get('title'),
    '#description' => '',
  ];
  $form['description'] = [
    '#title' => $this
      ->t('Description'),
    '#type' => 'textarea',
    '#default_value' => $this->dashboard
      ->get('description'),
    '#description' => '',
  ];
  $form['columns'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Dashboard columns'),
    '#options' => [
      1 => $this
        ->t('1 Column'),
      2 => $this
        ->t('2 Columns'),
      3 => $this
        ->t('3 Columns'),
      4 => $this
        ->t('4 Columns'),
    ],
    '#default_value' => $this->dashboard
      ->get('columns'),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
    '#button_type' => 'primary',
  ];
  return $form;
}