Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

html::formhandler::field::compound(3pm) [debian man page]

HTML::FormHandler::Field::Compound(3pm) 		User Contributed Perl Documentation		   HTML::FormHandler::Field::Compound(3pm)

NAME
HTML::FormHandler::Field::Compound - field consisting of subfields VERSION
version 0.40013 SYNOPSIS
This field class is designed as the base (parent) class for fields with multiple subfields. Examples are HTML::FormHandler::Field::DateTime and HTML::FormHandler::Field::Duration. A compound parent class requires the use of sub-fields prepended with the parent class name plus a dot has_field 'birthdate' => ( type => 'DateTime' ); has_field 'birthdate.year' => ( type => 'Year' ); has_field 'birthdate.month' => ( type => 'Month' ); has_field 'birthdate.day' => ( type => 'MonthDay'); If all validation is performed in the parent class so that no validation is necessary in the child classes, then the field class 'Nested' may be used. The array of subfields is available in the 'fields' array in the compound field: $form->field('birthdate')->fields Error messages will be available in the field on which the error occurred. You can access 'error_fields' on the form or on Compound fields (and subclasses, like Repeatable). The process method of this field runs the process methods on the child fields and then builds a hash of these fields values. This hash is available for further processing by "actions" in HTML::FormHandler::Field and the validate method. widget Widget type is 'compound' build_update_subfields You can set 'defaults' or other settings in a 'build_update_subfields' method, which contains attribute settings that will be merged with field definitions when the fields are built. Use the 'by_flag' key with 'repeatable', 'compound', and 'contains' subkeys, or use the 'all' key for settings which apply to all subfields in the compound field. AUTHOR
FormHandler Contributors - see HTML::FormHandler COPYRIGHT AND LICENSE
This software is copyright (c) 2012 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. perl v5.14.2 2012-06-25 HTML::FormHandler::Field::Compound(3pm)

Check Out this Related Man Page

HTML::FormHandler::Manual::Errors(3pm)			User Contributed Perl Documentation		    HTML::FormHandler::Manual::Errors(3pm)

NAME
HTML::FormHandler::Manual::Errors - FormHandler error methods VERSION
version 0.40013 SYNOPSIS
Manual Index Errors and error messages for HTML::FormHandler. 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. The existence (or not) of errors determines whether or not the form has been 'validated'. Form methods errors Returns an array of localized error strings (both field and form errors): my @errors = $form->errors; 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 have form_errors? 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. Field methods The 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'); } } 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, do 'has_error_fields'. num_errors add_error Add an error to the field. Localization is performed. push_errors Add an error without localization. error_fields In a compound field (and its subclasses, like 'Repeatable'), the list of fields with errors. 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. These are the main methods that you might need to use. has_errors errors error_results The results with errors; 'error_fields' is a wrapper around this. 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. 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 ); AUTHOR
FormHandler Contributors - see HTML::FormHandler COPYRIGHT AND LICENSE
This software is copyright (c) 2012 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. perl v5.14.2 2012-06-25 HTML::FormHandler::Manual::Errors(3pm)
Man Page