[Catalyst] Question about Catalyst::Controller::FormBuilder

Matt S Trout dbix-class at trout.me.uk
Mon May 14 14:48:04 GMT 2007


On Mon, May 14, 2007 at 01:22:43PM +0100, Richard Jones wrote:
> 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}$/';
> >
> >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?

That's lovely.

Screwing with CGI::FormBuilder globals isn't - it's an awful hack, not
clear to a maintenance developer and may have unforeseen consequences if
it's repeated across multiple codebases that might one day share a perl
interpreter.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Catalyst mailing list