You are here

public function BreakpointForm::form in Bootstrap Layout Builder 2.x

Same name and namespace in other branches
  1. 1.x src/Form/BreakpointForm.php \Drupal\bootstrap_layout_builder\Form\BreakpointForm::form()

Gets the actual form array to be built.

Overrides EntityForm::form

See also

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

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

File

src/Form/BreakpointForm.php, line 45

Class

BreakpointForm
Class BreakpointForm.

Namespace

Drupal\bootstrap_layout_builder\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  /** @var \Drupal\bootstrap_layout_builder\BreakpointInterface $breakpoint */
  $breakpoint = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $breakpoint
      ->label(),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $breakpoint
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\bootstrap_layout_builder\\Entity\\Breakpoint::load',
    ],
    '#disabled' => !$breakpoint
      ->isNew(),
  ];
  $form['base_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Base class'),
    '#maxlength' => 255,
    '#default_value' => $breakpoint
      ->getBaseClass(),
    '#required' => TRUE,
  ];
  $form['status'] = [
    '#title' => $this
      ->t('Enabled'),
    '#type' => 'checkbox',
    '#default_value' => $breakpoint
      ->getStatus(),
    '#description' => $this
      ->t('Determines if this breakpoint enabled.'),
  ];
  return $form;
}