Thank you for your reply :). I will take a look at that plugin.

In the meantime I managed to work out what was wrong if anyone is
interested.

Reading this post helped me: http://forum.symfony-project.org/index.php/m/85568/

I created the relationships between the objects correctly before the
embedding form. But the problem was I forgot to do that in the
executeCreate action as well! D'oh!

This meant adding a few hidden ID fields in the form so the objects
could be retrieved in the executeCreate action and  the relationships
between them could be created again before passing the object to the
form.
e.g.

public function executeCreate(sfWebRequest $request)
{

  $book = ObjectPeer::retrieveByPK($request->getParameter('book_id'))

  $author = new Author();
  $author->setBook($book);

  $form = new BookForm($book);

  << etc >>
}




On Jul 1, 5:57 pm, Daniel Lohse <[email protected]> wrote:
> You might want to take a look at 
> this:http://www.symfony-project.org/plugins/ahDoctrineEasyEmbeddedRelation...
>
> Cheers, Daniel
>
> On 01.07.2010, at 06:04, antonydb wrote:
>
>
>
> > Hello,
>
> > I'm having trouble validating a form. I have embedded another form
> > within it n times, where n is a number that can vary.
>
> > The validation seems to pass without error if the object is being
> > updated. However on insert the validator gives me the error:
>
> > Unexpected extra form field named "value1", Unexpected extra form
> > field named "value2", Unexpected extra form field named "value3"
>
> > I was hoping someone could shed some light on the best process for
> > embedding one form inside another n times.
>
> > I have a validator within my embedded form:
>
> > $this->validatorSchema['value'] = new
> > sfValidatorString( array('required' => true));
>
> > And I'm embedding it with a for loop:
>
> > foreach ($object_list as $n => $object)
> > {
> >  $this->embedForm('object'.$n, new ObjectForm($object));
> > }
>
> > And I guess on insert it validates properly for the first embedded
> > form as I am not receiving the error "Unexpected extra form field
> > named "value0".
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to 
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to