NAME
HTML::FormHandler::Manual::Reference - concise reference
VERSION
version 0.40068
DESCRIPTION
Manual Index
This is a concise reference of HTML::FormHandler.
HTML::FormHandler has a lot of options and many ways to customize your forms. More complete documentation can be found in the rest of the manual as HTML::FormHandler::Manual and in HTML::FormHandler, HTML::FormHandler::Field, HTML::FormHandler::Model::DBIC, HTML::FormHandler::Render::Simple, and in the individual field classes.
Form
Form Attributes
params HTTP parameters; if present validation will be attemptedname Form name. Used in 'id' of form elementfield_name_space Where to search for fieldswidget_name_space Where to search for widgetslanguage handle For MakeTextctx Application context for your useinit_object For default values instead of $itemdependency Array of arrays of field names. If one name has a value, allfields in the list are set to 'required'fields Field arraysorted_fields The sorted array of fieldsfield( $name ) Returns a field objecthas_field Moose-y sugar for declaring fieldsfield_list Non-moose-y way to define fieldsclear Resets state. Used in persistent forms.value Returns a hashref of values (with accessor keys)fif Returns a hashref for filling in form
Form database attributes
item DB row objectitem_class Class of db itemitem_id Primary key of db itemschema Schema of itemAlso 'update_model' sub
Form processing
process Sets up form, validates, updates modelrun Returns a result object and clears formupdate_field_list Updates to fields on processposted Flag to say whether or not to validate, instead ofdepending on presence of params
Validation
validate Sub for validation after individual fields are validatedvalidate_model Sub for additional database type validationvalidated Flag that form has validatedis_valid Synonym of 'validated'ran_validation Flag that validation has already been rundependency Set groups of fields that are set to required if one is presentvalidate_$fieldname Validation routine for field (also 'validate_method')
Errors
has_errors True if any field has errorsnum_errors The number of errors (field errors + form errors)error_fields An array of fields with errorserrors Returns an array of all errorserror_field_names Returns an array of field names with errors
Form Methods and process hooks
update_model To perform additional database actions on updateupdate_fields Sub providing convenient place to update fields on 'process'update_subfields Sub providing place to update fields on Build (useful forroles and compound field classes)init_object can be a method instead of an attribute
Form Rendering
html_prefix Flag to prefix html field names with the form name.Useful for multiple instances of the same formdo_form_wrapper flag to wrap form. (build_do_form_wrapper)form_tags Various strings and flags used by renderingform_element_attr For arbitrary html attributes in the 'form' tagform_element_class Arrayref of classes for 'class="..."' in form elementform_wrapper_attr For arbitrary html attributes on the form wrapperform_wrapper_class Arrayref of classes for 'class="..."' in form wrapperhttp_method For storing 'post' or 'get'action Store the form 'action' on submission. No default value.enctype Request enctypeuuid generates a string containing an HTML field with UUIDstyle adds a 'style' attribute to the form tagid the form tag 'id' attribute is set to the form namehtml_attributes hook that allows customizing html attributes (form & field)
Field specific form methods
options_$fieldname Sub returning options array (also 'options_method')validate_$fieldname Validation routine for field (also 'validate_method')default_$fieldname Set default for field (also 'default_method')
Fields
Field attributes
name Field name. Must be the same as database column name or reltype Field type. From a Field class: 'Text', 'Select', etcorder Set the order for fields. Default order is set by FH.dump For debuggingactive Arrayref of fields to set activeis_activeinactive Arrayref of fields to set inactiveis_inactiveinput_without_param The value of the field if there is no input from the submitted formdefault Default value for the fielddefault_method Coderef to set default or 'default_$fieldname' (by default)not_nullable Don't convert an empty field ('', etc) to undeftrim Transform to trim the fielddeflation Function to deflate the field (in 'apply') (opposite of transform)deflate_method Coderef to deflate the field (for filling in the form)inflate_method Coderef to inflate the field (before validation)inflate_default_method Coderef to inflate value from item/init_objectdeflate_value_method Coderef to deflate value after validationfif_from_value Flag to use 'value' of field for 'fif'.password Remove from params and do not display in forms.
Select fields
options Sorted array of hashes; keys: "value", "label"options_methodlabel_column Column to use for labels (default: name)active_column Which values to list in optionssort_column Column to use for sorting (default: label_column)
Field errors
errors Errors associated with this field(also num_errors, clear_errors, has_errors, add_error)messages Hashref of message identifiers and text
Field validation
apply Array of constraint/coercion/transformation actions( type, check, transform, message, when )validate_method Validation coderef, or 'validate_$fieldname' in form (default)required Field is requiredrequired_when Takes a hashref of field name keys and valuesmissing Flag set when a 'required' or 'required_when' failsmaxlength Text fields. Validated.minlength Text fields. Used in validationrange_start Range start for number fieldsrange_end Range end for number fields
Field attributes for DB
accessor Database accessor name if different than field nameunique Field should be unique in the databasenoupdate Don't update this field in the databasewriteonly Do not retrieve initial valuesAlso see the select field _columns attributes
Field rendering
widget Determines which rendering widget to use for the fieldwidget_wrapper Which wrapper widget to apply to the fieldelement_attr Hashref to store arbitrary html attributes.label_attr Hashref for html attributes for the labelwrapper_attr Hashref for html attributes for the wrapping element (div, etc)element_class Arrayref for classes for the form elementwrapper_class Arrayref for classes for the form element wrapperlabel_class Arrayref for classes for the form element labellabel Text label for this field. Defaults to ucfirst field name.build_label_method provide a builder for 'label' attributewrap_label_method provide a coderef to wrap the labelid Useful for javascript (default is html_name. to prefix withform name, use 'html_prefix' in your form)build_id_method Provide a builder for 'id' attributedo_wrapper Flag to render wrapperdo_label Flag to render labelsize Text & select fields.render Widget method to render the field ($field->render)renderx "" plus set attributes ($field->render( element_class => '...' ))render_element Widget method to render unwrapped field ($field->render_element)render_elementx "" plus set attributes ($field->render_elementx( element_class => '...'))
Field attributes managed by FormHandler
These attributes are usually accessed in a subroutine or in a template, but are usually set only by FormHandler. ('value' may be changed as a transform _in a validation routine_.)
init_value Initial value from the databasevalue The value of your field.input Input value from parameter or initial value from databasefif Retrieve (do not set) values for filling in a form
AUTHOR
FormHandler Contributors - see HTML::FormHandler
COPYRIGHT AND LICENSE
This 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.