1. Arialdo Martini
    April 4, 2011 @ 5:08 am

    Interesting post.
    I’m working on an alternative approach, which you can find described here.


    I hope you can find it useful or at least inspiring 😉


  2. Florian
    September 14, 2011 @ 2:52 am

    made my day, thx 🙂


  3. chryssalid
    December 11, 2011 @ 5:51 pm

    Thanks for reminding the tips. Sometimes one forgot things like the one described at section 1.


  4. Shuro
    January 16, 2012 @ 9:41 am

    Point 3 saved the rest of my Workday….Okay, only a few hours left, but better than nothing.


    • nisdec
      February 7, 2012 @ 6:57 am

      /sign /sign /sign /sign

      I already spent a whole day on this. And without this nice tricky hack I would have spent another 2 days on that.

      Thank you so much for this.


      • Jacob Mather
        February 7, 2012 @ 9:02 am

        Glad you found this helpful!


  5. nisdec
    February 7, 2012 @ 8:50 am

    @Point 3: For Propel you just need a little modification:

    public function saveEmbeddedForms($con = null, $forms = null)
    parent::saveEmbeddedForms($con, $forms);


    • Jacob Mather
      February 7, 2012 @ 9:03 am

      Wonderful, thank you so much for adding to the other side of the equation. I stopped using Propel when I upgraded to symfony 1.4.


  6. Pedro Bueno
    June 6, 2012 @ 10:55 pm

    Ty SOOO much!!
    Your embedMergeForm saves my life =D


    • Jacob Mather
      June 6, 2012 @ 11:15 pm

      Thank you. I wish I could take credit for it, but that belongs to Roland Tapken


  7. Mike
    June 20, 2012 @ 4:30 pm


    I am correcting the embedMergeForm to take field position into account(when useFields and setPosition is used):

    Instead of using
    foreach ($form->getWidgetSchema()->getFields() as $field => $widget)

    use the getPositions to set widgets, like so:

    foreach ($form->getWidgetSchema()->getPositions() as $field)
    $widgetName = "$name-$field";

    if (isset($this->widgetSchema[$widgetName]))
    throw new LogicException("The forms cannot be merged. A field name '$widgetName' already exists.");

    $this->widgetSchema[$widgetName] = $form->widgetSchema[$field];
    // Copy widget
    $this->validatorSchema[$widgetName] = $form->validatorSchema[$field];
    // Copy schema
    $this->setDefault($widgetName, $form->getDefault($field));
    // Copy default value

    if (!$form->widgetSchema[$field]->getLabel())
    // Re-create label if not set (otherwise it would be named 'ucfirst($widgetName)')
    $label = $form->getWidgetSchema()->getFormFormatter()->generateLabelName($field);
    $this->getWidgetSchema()->setLabel($widgetName, $label);

    $prev = $widgetName;

    and replace


    • Jacob Mather
      June 20, 2012 @ 8:09 pm

      I haven’t tried this myself yet but this looks good.

      However it also looks like your comment got cut off — care to add the rest? 🙂


      • Mike
        June 21, 2012 @ 6:15 pm

        Sorry, I believe I was finished, “and replace” must have been something I was typing before copy&paste.. Basically just replace the original foreach with

        foreach ($form->getWidgetSchema()->getPositions() as $field)

        and then replace all ‘$widget’ references within the foreach with:



  8. Valentas
    October 21, 2013 @ 2:15 am

    #5: You can set up Validation engine to cascade embeded form validation. What You need is to create a separate Form type. Refer to symfony docs at: http://symfony.com/doc/current/reference/forms/types/form.html


Leave a Reply

Your email address will not be published. Required fields are marked *