public function UnitBundleForm::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/ UnitBundleForm.php, line 50 - Contains \Drupal\bat_unit\UnitBundleForm.
Class
- UnitBundleForm
- Form handler for unit bundle forms.
Namespace
Drupal\bat_unitCode
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\\UnitBundle',
'load',
],
'source' => [
'name',
],
],
'#description' => t('A unique machine-readable name for this type. It must only contain lowercase letters, numbers, and underscores.'),
];
return $this
->protectBundleIdElement($form);
}