I
I
Igor Chernyshev2011-12-13 16:56:07
symfony
Igor Chernyshev, 2011-12-13 16:56:07

[ Symfony 2 ] Consolidated Forms and Default Data

Good evening.

I have multiple forms (UserType, ClientType) and I want to make an edit page. To do this, I create a new form in the controller, combining them on the fly:

$form = $this->createFormBuilder()->add('user', new Form\UserType())
                                  ->add('client', new Form\ClientType())
                                  ->getForm();

How can I pass the default value to me for these forms ? Those. I want to transfer objects (entities) to the form and that the form would pull out the data from there on its own for substitution in the appropriate fields.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Chernyshev, 2011-12-14
@Vir

It so happened that I myself solved my problem, and even wrote a small topic on this topic.

P
png, 2011-12-16
@png

The first comment, to your own article. I did it in a similar way, but with a muscle, and my idea is a little wider.
I described the idea here
Later I made a task even more similar to yours. Combined several forms into one.
Wrote the general object, specified type for it. further wielded with this object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question