public function WorkspaceForm::form in Drupal 9
Same name and namespace in other branches
- 8 core/modules/workspaces/src/Form/WorkspaceForm.php \Drupal\workspaces\Form\WorkspaceForm::form()
- 10 core/modules/workspaces/src/Form/WorkspaceForm.php \Drupal\workspaces\Form\WorkspaceForm::form()
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- core/
modules/ workspaces/ src/ Form/ WorkspaceForm.php, line 66
Class
- WorkspaceForm
- Form controller for the workspace edit forms.
Namespace
Drupal\workspaces\FormCode
public function form(array $form, FormStateInterface $form_state) {
$workspace = $this->entity;
if ($this->operation == 'edit') {
$form['#title'] = $this
->t('Edit workspace %label', [
'%label' => $workspace
->label(),
]);
}
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $workspace
->label(),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#title' => $this
->t('Workspace ID'),
'#maxlength' => 255,
'#default_value' => $workspace
->id(),
'#disabled' => !$workspace
->isNew(),
'#machine_name' => [
'exists' => '\\Drupal\\workspaces\\Entity\\Workspace::load',
],
'#element_validate' => [],
];
return parent::form($form, $form_state);
}