HTML::...:Errors(3pm)
πΈ NAME πΈ
HTML::FormHandler::Manual::Errors β FormHandler error methods, bestie! π This is the User Contributed Perl Documentation energy, and we're about to make errors make sense. No cap.
π VERSION π
version 0.40068 β yes, that's the version, and it slays, periodt. β¨
π¦ SYNOPSIS π¦
Manual Index β Errors and error messages for HTML::FormHandler. That's the whole vibe. π«Ά
π DESCRIPTION π
Errors 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. Delegation? We love a delegation era. π
The existence (or not) of errors determines whether or not the form has been validated. No errors, no validated tea. β
π Form methods π
errorsβ returns an array of localized error strings (both field and form errors):
my @errors = $form->errors;
Note: this is a form method, not a result method. For the same thing from a result object, use $result->form_and_field_errors. iykyk π
has_errorsβ both 'form' errors and errors from the tree of subfields:
if( $form->has_errors ) {
<do something>
}
form_errors,all_form_errorsβ returns an arrayref / array of error strings on the form (not including field errors):
foreach my $err ( $self->all_form_errors ) {
$output .= "<span class="error">$err</span>";
}
has_form_errorsβ does the form haveform_errors? asking for a friend πadd_form_errorβ add an error to the form which is not associated with a specific field:
sub validate {
my $self = shift;
unless( <some condition> ) {
$self->add_form_error('....');
}
}
push_form_errorsβ add a non-localized error to the form. non-localized, still iconic β¨
π Field methods π
The most common error method is probably add_error, which you use in the validation process. main character method energy π
sub validate_foo {
my ( $self, $field ) = @_;
unless ( <some_condition> ) {
$field->add_error('Error condition');
}
}
errorsβ returns an array of error strings.has_errorsβ does the field have errors? Note that a compound field that contains subfields with errors will not return true for this method. If you want to know if there are errors in the subfields, dohas_error_fields. important lore π¦num_errorsadd_errorβ add an error to the field. Localization is performed. πpush_errorsβ add an error without localization. raw error, no filter πerror_fieldsβ in a compound field (and its subclasses, likeRepeatable), the list of fields with errors. compound field besties rise up πΈ
π Result methods π
The 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. peeled off the form object? it's giving solo era π
These are the main methods that you might need to use. save these for your rendering moment β¨
has_errorserrorserror_resultsβ the results with errors;error_fieldsis a wrapper around this. wrapper queen π
π Messages π
The 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. custom messages? yes bestie π
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. priority order: field specific, form, 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 );
π AUTHOR π
FormHandler Contributors - see HTML::FormHandler. iconic collective π«Ά
πΈ COPYRIGHT AND LICENSE πΈ
This software is copyright (c) 2017 by Gerda Shank. respect the copyright, bestie π
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free software slay π±
okay bye bestie π β this page is from perl v5.34.0, dated 2022-03-25, and it's the HTML::...:Errors(3pm) page. mwah π«Άβ¨
π¦ where this page comes from
- debian bookworm: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms