A fresh supply of thoughts about Web Development & Mac OS X
Months ago I wrote about the validation of checkboxes in Symfony and how it could fill your database with wrong values.
I recommended downloading, or writing, a small validator which checked if the value of the checkbox is zero or one. But there’s a much simpler solution to this problem.
If you use a numerical value for your radiobuttons/checkboxes, simply call the sfNumberValidator with zero as an minmum and one as an maximum.
tos:
sfNumberValidator:
min: 0
max: 1
If you use strings, such as ‘male’ or ‘female’ for a gender radiobutton, the sfStringValidator is the right choice:
sfStringValidator:
values: ['male', 'female']
value_error: Invalid value
Published: April 2, 2008 — Tagged: php, symfony, validation
© 2008 Arthur Koziel — About | Archive | Colophon | Contact | Feeds