Archive > Tag > Symfony
It’s now been over a month since my last post to this blog. I had promised not to ever let it get longer than 10 days but this past month has been an exceptional circumstance. I’ve had a few enquiries regarding part 3 of my YUI articles, so this post is just a quick update to say it’s still on it’s way!
Generally, when I find something interesting I use twitter & delicious to spread the word, but this morning something in my RSS Reader got me excited enough to decide to write a blog post. Thomas Rabaix has hit the nail on the head with his latest offering: Wording is not a developer job. Not only with his underlying premise, but also with the solution he has developed and offered to the world.
Back in April I posted a Snippet on Symfony Form Formatters. Since then I’ve done a bit more work with them and thought I’d share my custom form formatter for displaying forms as definition lists. Forms are often marked up as unordered lists, but with their label-input structure I find they often make semantic sense as definition lists.
Symfony is one of my favourite bits of technology. I’ve got plans to write several articles and tutorials on it, but as I know many people haven’t yet heard of it, or are unaware of how it could help them, I thought it best to write an introductory article. So, here is an explanation of what Symfony is, why I use it, and why you may want to start using it too.
By default Symfony displays forms in tables, with each new input being a table row. If you want to display your forms more semantically with fieldsets and lists, Symfony has a list formatter built in. You can tell an individual form to display as a list using the code below.
1 2 3 4 5 6 | <?php // lib/form/MyModelForm.class.php public function configure() { $this->widgetSchema->setFormFormatterName('list'); } ?> |
I often forget how to set default values for form fields. Mainly because it’s a function of sfForm rather than sfFormField I think. I the snippet below ‘field’ you are setting the default value for, and $value should be the default value.
1 | $this->setDefault('field', $value); |
The following snippets provide access to the Symfony User object from various parts of a Symfony project.
Place this line of code in the configure method of a Symfony form to allow the saving of additional fields.
1 2 3 4 5 6 | <?php // lib/form/MyModelForm.class.php public function configure() { $this->validatorSchema->setOption('allow_extra_fields', true); } ?> |











