Posts Tagged forms
Symfony 1.1+ Form Template
Posted by PhazeonPhoenix in Symfony on July 4th, 2009
In my work with Symfony I’ve started collecting a library of code snippets that I use to speed up my creation of different objects in the Symfony tree. Since most of them are cut and splices of other people’s code (especially the Symfony documentation) I’m going to start posting some of the better ones on my blog.
The one that I’m going to share today involves the creation of a form class for the new form handling classes added in Symfony 1.1. I found myself constantly having to go back to the form and adding the sections that I needed but forgot the list time I was working it. I created this template and included all of the options I felt I’d need to declare to correctly implement a nice looking and behaving form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <?php /** * Template Form * * @author Phazeon Phoenix <phoenix@phazeon.com> * @version 1 * @copyright 2009 Phazeon.com * @package Forms */ class templateForm extends sfForm { public function configure() { $this->setWidgets(array( )); $this->setValidators(array( )); $this->setDefaults(array( )); $this->widgetSchema->setLabels(array( )); $this->widgetSchema->setFormFormatterName('list'); $this->widgetSchema->setNameFormat('template[%s]'); } } |
