Matt S Trout wrote:
On Sun, May 13, 2007 at 10:43:31AM -0700, Balaji Srinivasan wrote:
Rather than the two approaches above, I think a better one was to add a new
validation type to the FormBuilder VALIDATE array.
$CGI::FormBuilder::Field::VALIDATE{FOOFIELD} = '/^[^,"]{6,40}$/';
Now in all my forms, i just set the validate field to FOOFIELD.
This works great for me. It avoide me having to write my own validation code
and also avoids the need to add the regex to each form.
If this is a personal project and you'll always be the only developer, fine.
If this is commercial work I consider it a terrible idea, but I hold my
commercial work to high standards.
Bad idea because it's being done this way, or because it is being done
at all?
I ask because I also extended the validation fields, but in a CCF
sub-class under the Controller::FormBuilder config option. eg
__PACKAGE__->config(
'Controller::FormBuilder' => {
new => {
# stuff,
},
validate => {
# new or over-ridden validation options
}
and my controllers inherit this. Is that an OK way to do it?
--
Richard Jones
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/