public function GroupContentMenuTypeForm::form in Group Content Menu 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
- src/
Form/ GroupContentMenuTypeForm.php, line 18
Class
- GroupContentMenuTypeForm
- Form handler for group content menu type forms.
Namespace
Drupal\group_content_menu\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$entity_type = $this->entity;
if ($this->operation == 'add') {
$form['#title'] = $this
->t('Add group menu type');
}
else {
$form['#title'] = $this
->t('Edit %label group menu type', [
'%label' => $entity_type
->label(),
]);
}
$form['label'] = [
'#title' => $this
->t('Label'),
'#type' => 'textfield',
'#default_value' => $entity_type
->label(),
'#description' => $this
->t('The human-readable name of this group menu type.'),
'#required' => TRUE,
'#size' => 30,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $entity_type
->id(),
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
'#machine_name' => [
'exists' => [
GroupContentMenuType::class,
'load',
],
'source' => [
'label',
],
],
'#description' => $this
->t('A unique machine-readable name for this group menu type. It must only contain lowercase letters, numbers, and underscores.'),
];
return $this
->protectBundleIdElement($form);
}