0

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!

1 Answer 1

1

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'] ?>
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for answer.it is very helpful. I have one more question. When I generate these models from command line, base class fields are automatically set to "$this->setWidgets(...)". Can I configure symfony so that automatically created model fields are set to "$general=sfWidgetFormSchema(array('name'=> new fWidgetFormInputText(),...)"..Thanks
I am affraid that it's not possible. But, maybe you can try something with the inheritence system in the class Productform wich must be inherited in other form like desktop...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.