[Html-widget] FormFu: form_error_message not an error?

Jason Kohles email at jasonkohles.com
Mon Apr 30 21:02:38 GMT 2007


On Apr 30, 2007, at 2:44 PM, Carl Franks wrote:

> On 30/04/07, Jason Kohles <email at jasonkohles.com> wrote:
>> It seems that setting form_error_message on a form that has no other
>> errors will not have any effect.  Is this the intended behavior, and
>> if so does anyone else think it doesn't make sense?  :)  In
>> particular, I was trying to use form_error_message as a kind of
>> 'error-handler of last resort', by doing this in a Catalyst app:
>>
>> if ( $form->submitted_and_valid ) {
>>      my $user = $c->model( 'DB::User' )->new( {} );
>>      eval { $user->populate_from_formfu( $form ) };
>>      if ( $@ ) {
>>          $c->log->error( $@ );
>>          $form->form_error_message( "FATAL ERROR: $@" );
>>      } else {
>>          $c->post_redirect( '/thank_you' );
>>      }
>> }
>>
>> Does it seem like this should work, or does anyone have a suggestion
>> for a better way to handle this?
>
> form_error_message only sets the message that should be used - I
> imagine it usually being set to a localisation string in your config
> file, so it needn't change at run time.
> I think we need a new method which forces the error message to be
> rendered, even if there are no field-errors.
> Could you add a RFE to the issue tracker, for this?
> http://code.google.com/p/html-formfu/issues/list
>

As far as I can tell, it's just a one-line change to the  
form_error_message template...

Index: HTML-FormFu/root/form_error_message
===================================================================
--- HTML-FormFu/root/form_error_message (revision 194)
+++ HTML-FormFu/root/form_error_message (working copy)
@@ -1,1 +1,1 @@
-[% IF self.form_error_message.defined && self.form.has_errors %]
+[% IF self.form_error_message.defined %]

-- 
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire





More information about the Html-widget mailing list