public function EntityDescriptionFormTrait::form in Lightning Core 8
Same name and namespace in other branches
- 8.5 src/EntityDescriptionFormTrait.php \Drupal\lightning_core\EntityDescriptionFormTrait::form()
- 8.2 src/EntityDescriptionFormTrait.php \Drupal\lightning_core\EntityDescriptionFormTrait::form()
- 8.3 src/EntityDescriptionFormTrait.php \Drupal\lightning_core\EntityDescriptionFormTrait::form()
- 8.4 src/EntityDescriptionFormTrait.php \Drupal\lightning_core\EntityDescriptionFormTrait::form()
File
- src/
EntityDescriptionFormTrait.php, line 15
Class
- EntityDescriptionFormTrait
- Adds description support to entity forms.
Namespace
Drupal\lightning_coreCode
public function form(array $form, FormStateInterface $form_state) {
/** @var \Drupal\Core\Entity\EntityInterface|\Drupal\Core\Entity\EntityDescriptionInterface $entity */
$entity = $this
->getEntity();
$form = parent::form($form, $form_state);
$form['description'] = [
'#type' => 'textarea',
'#title' => t('Description'),
'#description' => $this
->t('Additional relevant information about this @entity_type, such as where it is used and what it is for.', [
'@entity_type' => $entity
->getEntityType()
->getSingularLabel(),
]),
'#rows' => 2,
'#default_value' => $entity
->getDescription(),
];
return $form;
}