SfWidgetFormChoice* with spicy empty values

To pass empty values to the widgets based on choices is really simple with symfony.

For example, the sfWidgetFormDoctrineChoice accepts a with_empty option, which can be a boolean or a string:

1
2
3
<?php

new sfWidgetFormDoctrineChoice(array('model' => 'ModelName', 'add_empty' => ...));

which renders the empty option according to the following rules:

1
2
3
4
given true:
  null => ''
given a string:
  null => 'string' 

The other widget I was working on, sfWidgetFormI18nDate, accepts an array to configure empty options:

1
2
3
<?php

new sfWidgetFormI18nDate(array('culture' => 'en', 'empty_values' => $empty_values));

with the following format:

1
2
3
4
Array
  day:   Day
  month: Month
  year:  Year

and the rendered form is something like this:


Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 160+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $9.99

In the mood for some more reading?

...or check the archives.