Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('contacts', ChoiceType::class, [
- 'label' => 'Contact',
- 'placeholder' => 'Choose a contact',
- 'choices' => $this->getContacts(),
- 'mapped' => false,
- ])
- ->setMethod('POST')
- ;
- $builder->get('contacts')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
- $contactId = $event->getData();
- $parentForm = $event->getForm()->getParent();
- $contactEntity = $exampleEm->getrepository(Contact::class)->find($contactId);
- $firstName = $contactEntity->getFirstName();
- // where can I set the 'contactFirstname' data ?
- $parentForm
- ->add('contactFirstname', TextType::class, [
- 'label' => 'First name',
- ]);
- })
- ;
- }
Add Comment
Please, Sign In to add comment