Ask your Symfony questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How do I embed forms when auto-generating admin modules? Symfony


This is Symfony 1.4, using Propel.

I have a site where the user admin is auto-generated with commands like this:

./symfony propel:generate-admin --theme="roboo" --module="deal" frontend Deal

But the "deal" table (and model) has a notification_id that links to the notification table. The relationship is one-to-one -- each deal gets one notification, and each notification is unique to a deal (though the notifications can actually be given out to many different models, including the tables for events, places, people, etc).

I want to embed the notification form in the deal form, so both are shown to the user as a single form. I know how to do this when I'm writing the action code myself, but in this case much of the code is auto-generated. Is there a way to do embedded forms with the generate-admin command?

Answers (3)


Milena Dimitrova answers:

I don't think the generator can help you for this but it can be easily achieved by adding the following custom methods to your DealForm:

public function configure()


$type = $this->getObject()->getNotification();
$this->embedForm('notification', new NotificationForm($type));



protected function doSave($con = null)
if (null === $con)
$con = $this->getConnection();


//gets called first

// same object after saving the embedded form

Having this in your form while using the standard generator command and unmodified generator.yml (form: ~) should display the embedded Notification form as an inalienable part of the Deal form.

Lawrence Krubner comments:

Hmm, and how are these changes made visible? I changed the form class and then regenerated the module with:

./symfony propel:generate-admin --theme="roboo" --module="deal" frontend Deal

but I don't see any changes in the forms.

Lawrence Krubner comments:

See screenshot. I cleared cache but I am still not seeing the embedded form. Not sure why.