I'm trying to get the entity inside the own form. I lazy remember a getData() method, but it doesn't exist inside the form, and I can't remember how to use it.
Is there any way to get the entity inside the buildform method not using an event listener?
I mean, something like this:
public function buildForm(FormBuilderInterface $builder, array $options) { /*some method to get the entity of the form such as getEntity????????*/ $builder->add('field'); }
I found it:
public function buildForm(FormBuilderInterface $builder, array $options) { $entity = $builder->getData(); $builder->add('field'); }
2.1m questions
2.1m answers
60 comments
57.0k users