I've been trying to get it so I can embed x number of forms in a top form for a 1-m relationship. The simple example I have been testing is that I have a User who has many Emails.
User:
columns:
first_name: string(255)
last_name: string(255)
Email:
columns:
user_id: integer
address: string(255)
relations:
User:
I'm embedding the form in the action for ease of seeing what's going on. I would normally move this into the form class.
public function executeIndex(sfWebRequest $request)
{
$this->form = new UserForm();
$email_form = new EmailForm();
$this->form->embedForm('Email[0]', $email_form);
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter('user'));
if ($this->form->isValid())
{
$this->form->save();
}
}
}
When I do this the form displays properly, but when I submit the form validation fails with the following error:
- Unexpected extra form field named "Email".
It seems this not a limit of doctrine but a bug in symfony. I had tried previously doing this with plain sfForms and had similar results.
Google Groups Thread: http://groups.google.com/group/symfony-users/browse_frm/thread/b006b0a56696d75d