You are here

public function BlocktabsFormBase::form in Block Tabs 8

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

1 call to BlocktabsFormBase::form()
BlocktabsEditForm::form in src/Form/BlocktabsEditForm.php
Gets the actual form array to be built.
1 method overrides BlocktabsFormBase::form()
BlocktabsEditForm::form in src/Form/BlocktabsEditForm.php
Gets the actual form array to be built.

File

src/Form/BlocktabsFormBase.php, line 51

Class

BlocktabsFormBase
Base form for blocktabs add and edit forms.

Namespace

Drupal\blocktabs\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Blocktabs name'),
    '#default_value' => $this->entity
      ->label(),
    '#required' => TRUE,
  ];
  $form['name'] = [
    '#type' => 'machine_name',
    '#machine_name' => [
      'exists' => [
        $this->entityStorage,
        'load',
      ],
    ],
    '#default_value' => $this->entity
      ->id(),
    '#required' => TRUE,
  ];
  $form['#tree'] = FALSE;
  $form['settings'] = [
    '#type' => 'details',
    '#title' => t('Tabs settings'),
  ];
  $default_event = $this->entity
    ->getEvent();
  if (empty($default_event)) {
    $default_event = 'mouseover';
  }
  $form['settings']['event'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Select an event'),
    '#default_value' => $default_event,
    '#options' => [
      'mouseover' => $this
        ->t('Mouseover'),
      'click' => $this
        ->t('Click'),
    ],
  ];
  $default_style = $this->entity
    ->getStyle();
  if (empty($default_style)) {
    $default_style = 'default';
  }
  $form['settings']['style'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Style'),
    '#default_value' => $default_style,
    '#options' => [
      'default' => $this
        ->t('Default tabs'),
      'vertical' => $this
        ->t('Vertical tabs'),
      'accordion' => $this
        ->t('Accordion'),
    ],
  ];
  return parent::form($form, $form_state);
}