|
NAMEHTML::FormHandler::Manual::Errors - FormHandler error methodsVERSIONversion 0.40068SYNOPSISManual IndexErrors and error messages for HTML::FormHandler. DESCRIPTIONErrors are added to field or form objects by the field 'add_error' method or the form 'add_form_error' method. FormHandler will perform the 'add_error' for you for built-in validation or 'apply' actions. When performing your own validation in a validation method, you must do the 'add_error' yourself.Errors, along with 'input' and 'value' attributes, are collected in the FormHandler 'result' objects. A number of error retrieving methods are delegated to the field and form classes. The existence (or not) of errors determines whether or not the form has been 'validated'. Form methods
Field methodsThe most common error method is probably 'add_error', which you use in the validation process.sub validate_foo { my ( $self, $field ) = @_; unless ( <some_condition> ) { $field->add_error('Error condition'); } }
Result methodsThe input, value, and error attributes are actually stored in the result objects. Although most of the methods are delegated to the form and field classes, there are times, such as when rendering (because you might be rendering a result that's been peeled off of the form object), that you may need to use result methods.These are the main methods that you might need to use.
MessagesThe base field class and the field subclasses have some 'built-in' error messages. These can be modified by setting the 'messages' hashref in the form or the individual fields.When a message is retrieved in a field with "$field->get_message('upload_file_')" for example, the 'get_message' method will look first in user-set field specific messages, then in user-supplied form messages, finally in messages provided by the field classes. package MyApp::Form; use HTML::FormHandler::Moose; extends 'HTML::FormHandler'; sub build_messages { return { required => '....', my_message => '....' }; } ... my $form = MyApp::Form->new( messages => { required => '...', ...} ); ... has_field 'my_field' => ( messages => { required => 'Please provide a my_field' }, required => 1 ); AUTHORFormHandler Contributors - see HTML::FormHandlerCOPYRIGHT AND LICENSEThis software is copyright (c) 2017 by Gerda Shank.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |