On 30/04/07, Jason Kohles <[EMAIL PROTECTED]> wrote:
On Apr 30, 2007, at 2:44 PM, Carl Franks wrote: > On 30/04/07, Jason Kohles <[EMAIL PROTECTED]> 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/listAs far as I can tell, it's just a one-line change to the form_error_message template...
No, the current behaviour is intentional. It allows you to set a generic error message that will be displayed whenever there's any errors. The default I18N files include a 'form_error_message' string - so you can set form_error_message_loc: form_error_message in your config file to enable the message. I've added a new method: $form->force_error_message(1) which when true forces the form_error_message to be displayed, even if there were no field errors. The value will have no effect on $form->has_errors() or the like. This is in svn r200, and there's a test file at t/form/force_error_message.t Cheers, Carl _______________________________________________ Html-widget mailing list [email protected] http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
