You are here

public function TypeBundleForm::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_unit/src/TypeBundleForm.php, line 50
Contains \Drupal\bat_unit\TypeBundleForm.

Class

TypeBundleForm
Form handler for type bundle forms.

Namespace

Drupal\bat_unit

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_unit\\Entity\\TypeBundle',
        '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);
}