public function ParagraphsSetForm::form in Paragraphs Sets 8
Same name and namespace in other branches
- 8.2 src/Form/ParagraphsSetForm.php \Drupal\paragraphs_sets\Form\ParagraphsSetForm::form()
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/ ParagraphsSetForm.php, line 23
Class
- ParagraphsSetForm
- Form controller for paragraph set forms.
Namespace
Drupal\paragraphs_sets\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$paragraphs_set = $this->entity;
if (!$paragraphs_set
->isNew()) {
$form['#title'] = $this
->t('Edit %title paragraph set', [
'%title' => $paragraphs_set
->label(),
]);
}
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $paragraphs_set
->label(),
'#description' => $this
->t("Label for the Paragraphs set."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $paragraphs_set
->id(),
'#machine_name' => [
'exists' => 'paragraphs_set_load',
],
'#maxlength' => 32,
'#disabled' => !$paragraphs_set
->isNew(),
];
$form['description'] = [
'#title' => $this
->t('Description'),
'#type' => 'textarea',
'#default_value' => $paragraphs_set
->getDescription(),
];
return $form;
}