public function ParagraphsCategoryForm::form in Paragraphs Editor Enhancements 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/ ParagraphsCategoryForm.php, line 37
Class
- ParagraphsCategoryForm
- Form handler for the add and edit forms of Paragraphs category entities.
Namespace
Drupal\paragraphs_ee\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\paragraphs_ee\ParagraphsCategoryInterface $paragraphs_category */
$paragraphs_category = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $paragraphs_category
->label(),
'#description' => $this
->t("Label for the Paragraphs category."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $paragraphs_category
->id(),
'#machine_name' => [
'exists' => [
$this,
'exist',
],
],
'#disabled' => !$paragraphs_category
->isNew(),
];
$form['description'] = [
'#type' => 'textarea',
'#title' => $this
->t('Description'),
'#rows' => 3,
'#default_value' => $paragraphs_category
->getDescription(),
'#description' => $this
->t("Description for the Paragraphs category."),
'#required' => FALSE,
];
$form['weight'] = [
'#type' => 'weight',
'#title' => $this
->t('Weight'),
'#default_value' => $paragraphs_category
->getWeight(),
];
return $form;
}