[Catalyst] Re: Form validation in insert() and update()?

Dave Rolsky autarch at urth.org
Sun May 20 06:39:00 GMT 2007


On Sun, 20 May 2007, A. Pagaltzis wrote:

> * Dave Rolsky <autarch at urth.org> [2007-05-15 01:00]:
>>  eval
>>  {
>>      $user->update( %bunch_of_stuff );
>>  };
>>
>>  if ( my $e = Exception::Class->caught(
>>  'My::App::Exception::DataValidation') )
>>  {
>>      # $e->errors contains multiple data validation error messages
>>      # stuff them in the session
>>      # save the user's form submission in the session
>>      # redirect back to form
>>  }
>>  elsif ( my $e = $@ )
>>  {
>>      die $e;
>>  }
>>
>> Then on the display side, I check the session for error
>> messages and saved form arguments, and do something useful with
>> them.
>
> Surely you mean the stash, not the session?

No, I mean the session. I always keep the URIs for my form display and 
form submission separate, and I do a redirect after form submission.

In the Catalyst case, I generally take advantage of the flash feature, 
since it's perfect for this sort of stuff.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/



More information about the Catalyst mailing list