qasanov
qasanov

Reputation: 437

Symfony dynamic model form template

I am developing symfony based web application. I have many Models (Laptop, Netbook, Ipad,Tablet.... all these models inherited from Product model).Based on these models I also have Forms (LaptopForm, NetbookForm...so on). In my action class I get Model name and assign it to template :

 $modelForm = $this->modelName.'Form';

 $this->form = new $modelForm();

Then in my template I do that <?php echo $form ?> ..There is no problem it prints all fields and labels in html table.

But my problem is that I want to divide template in to 2 parts. General and special fieldset.In general fields set i want to display Product model fields(name,price...).But Special field set changes according to product type. How I can handle this special fields set?Can someone give a clue or source please?

Thanks in advance!

Upvotes: 0

Views: 672

Answers (1)

dxb
dxb

Reputation: 931

You can manage it manually, in your specialized form class (not alter the base class).
Perhaps, with the use of sfWidgetFormSchema :
http://www.symfony-project.org/forms/1_4/en/A-Widgets#chapter_a_sfwidgetformschema You have to name the widget 'general' and 'special', for a stanhdard re-use in form template, like this :

<?php echo $form['general'] ?>
<?php echo $form['special'] ?>

Upvotes: 1

Related Questions