public static function TwigTweakExtension::drupalEntityForm in Twig Tweak 3.x
Same name and namespace in other branches
- 3.1.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::drupalEntityForm()
Gets the built and processed entity form for the given entity type.
File
- src/
TwigTweakExtension.php, line 182
Class
- TwigTweakExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public static function drupalEntityForm(string $entity_type, ?string $id = NULL, string $form_mode = 'default', array $values = [], bool $check_access = TRUE) : array {
$entity_storage = \Drupal::entityTypeManager()
->getStorage($entity_type);
$entity = $id ? $entity_storage
->load($id) : $entity_storage
->create($values);
if ($entity) {
return \Drupal::service('twig_tweak.entity_form_view_builder')
->build($entity, $form_mode, $check_access);
}
return [];
}