Customizing symfony autogenerated forms
I'm trying to use auto-generated forms in symfony, but I have troubles finding good up to date articles about customization. One of the most important thing is - queries from / updates to several tables.
Speci开发者_StackOverflowficaly, example: there's table tblMain and auto-generated class tblMainForm I use. However, column ForeignKey references to tblAdditionalTable's id column. My autogenerated form displays a html select with those id numbers. What I really need is obviously appropriate values of specific column from AdditionalTable, not just id. And besides I dont need select here but custom ajax combobox instead; so that users would be able to enter their own values; which in turn would be stored in tblAdditionalTable.
So in short, is there an easy way to customize forms like that (links to articles would be most appreciated)? Or maybe it's better to write my own symfony form handling class instead of using Doctrine's one?
What you need to look at is changing the widget for the select box.
In the tblMainForm configure method you can change widgets like this:
$this->setWidget("foreign_key_id", new sfWidgetFormJQueryAutocomplete());
Have a look at http://www.symfony-project.org/plugins/sfFormExtraPlugin for some extra widgets.
Also this section goes into more detail about customising the forms generated by symfony
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/10#chapter_10_sub_customizing_the_job_form
精彩评论