Hi!

I have/had the same problem here and spent the last hours on this (i
would say simple) problem :).

Anyway overwriting the save method in the model doesn't work, I get a
SQLSTATE[23000]: Integrity constraint violation.

So I was thinking of overwriting the saveEmbeddedForms function in the
"parent-form" (the one that embeds the proposals in your example). I
can't imagine this is the smartest solution, but it works:

<code>
public function saveEmbeddedForms($con = null, $forms = null)
{
    if (is_null($con))
                {
      $con = $this->getConnection();
    }

    if (is_null($forms))
    {
      $forms = $this->embeddedForms;
    }

    foreach ($forms as $form)
    {
      if ($form instanceof sfFormDoctrine)
      {
        if (!($form->getObject() instanceof NoeQuizProposal))
        {
                $form->getObject()->save($con);
                $form->saveEmbeddedForms($con);
        }
        // condition to find out if the form is empty
        else if (strlen(trim((string)$form->getObject()->label)) > 0)
        {
                $form->getObject()->save($con);
                $form->saveEmbeddedForms($con);
        }
      }
      else
      {
        $this->saveEmbeddedForms($con, $form->getEmbeddedForms());
      }
    }
  }
</code>
-- 
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.


Reply via email to