[Catalyst] Where to put FormValidator profiles?

Perrin Harkins perrin at elem.com
Thu Aug 11 21:57:39 CEST 2005


On Thu, 2005-08-11 at 11:32 -0700, Bill Moseley wrote:
> > I keep, or generate (as necessary) my profiles in the Model class of
> > the main table I'm dealing with. I have a get_profile() method that
> > either returns a canned profile, or dynamically generates one,
> > depending on what I need to do. Then in my Controller I just say
> > my $profile = MyApp::M::Library->get_profile or whatever.

I do it this way too.

> On the other hand, I'm not sure how well that works when a form is
> submitted that will end up updating many different tables.

I just grab the profiles from multiple models and put them together.  It
requires some coordination to keep the form field names unique though.

> My original plan was to create a Plugin to replace the FormValidator
> plugin that calls DVF::new() instead of DFV::check() in the prepare
> method so I could pre-load named profiles.
> 
> But, I need to know $class and $primary_column inside the profile at run
> time, so I don't think there's a way to define this as a named profile
> in a call to Data::FormValidator->new().

You could manage your own lookup table of named profiles.  Profiles are
just data structures, so they can be stored and shared in the usual Perl
ways.

- Perrin




More information about the Catalyst mailing list