I'm trying to consolidate my form processing by entity_type, without rebuilding the forms (just using the default forms provided by Drupal.
I have dynamic routes pointing to a _controller::method. I've tried:
- A.
\Drupal::service('entity.form_builder')->getForm($group_content, 'edit', $data)
but this just returns a render array, no instance. - B.
\Drupal::formBuilder()->getForm('\Drupal\group\Entity\Form\GroupContentForm')
but this is the wrong class path and i can't figure out how I could reference any entity:bundle:id by any pattern (i've tried many) - C. Changed the route to use
_form
or_entity_form
extendingFormBase
(instead of a controller), but it seems these require thebuildForm
method to defined the form's full field list (which defeats the purpose of my question).
What is the best approach to expose edit/add/delete process handlers for multiple bundles / entity_type in a single class?