You are here

public function BookingBundleForm::form in Booking and Availability Management Tools for Drupal 8

Gets the actual form array to be built.

Overrides EntityForm::form

See also

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

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

File

modules/bat_booking/src/BookingBundleForm.php, line 50
Contains \Drupal\bat_booking\BookingBundleForm.

Class

BookingBundleForm
Form handler for type bundle forms.

Namespace

Drupal\bat_booking

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $type = $this->entity;
  $form['name'] = [
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#default_value' => $type
      ->label(),
    '#description' => t('The human-readable name of this type.'),
    '#required' => TRUE,
    '#size' => 30,
  ];
  $form['type'] = [
    '#type' => 'machine_name',
    '#default_value' => $type
      ->id(),
    '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
    '#disabled' => FALSE,
    '#machine_name' => [
      'exists' => [
        'Drupal\\bat_booking\\Entity\\BookingBundle',
        'load',
      ],
      'source' => [
        'name',
      ],
    ],
    '#description' => t('A unique machine-readable name for this type. It must only contain lowercase letters, numbers, and underscores.'),
  ];
  $form['advanced'] = [
    '#type' => 'vertical_tabs',
    '#attributes' => [
      'class' => [
        'entity-meta',
      ],
    ],
    '#weight' => 99,
  ];
  return $this
    ->protectBundleIdElement($form);
}