Skip to content

Commit

Permalink
Merge pull request #33 from tamias/doc-fixes
Browse files Browse the repository at this point in the history
More documentation fixes
  • Loading branch information
gshank committed Jun 21, 2012
2 parents 6014e29 + 7128ef5 commit 6f3948c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
31 changes: 15 additions & 16 deletions lib/HTML/FormHandler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ created using the 'field_list' attribute to set fields:
field_list => [
'username' => {
type => 'Text',
apply => [ { check => qr/^[0-9a-z]*/,
apply => [ { check => qr/^[0-9a-z]*\z/,
message => 'Contains invalid characters' } ],
},
'select_bar' => {
Expand Down Expand Up @@ -151,7 +151,7 @@ You can split the pieces of your forms up into logical parts and compose
complete forms from FormHandler classes, roles, fields, collections of
validations, transformations and Moose type constraints.
You can write custom methods to process forms, add any attribute you like,
use Moose method modifiers. FormHandler forms are Perl classes, so there's
and use Moose method modifiers. FormHandler forms are Perl classes, so there's
a lot of flexibility in what you can do.
HTML::FormHandler provides rendering through roles which are applied to
Expand All @@ -162,7 +162,7 @@ L<HTML::FormHandler::Render::Table> that contain methods for rendering
field widget classes, and the L<HTML::FormHandler::Widget> roles, which are
more atomic roles which are automatically applied to fields and form. See
L<HTML::FormHandler::Manual::Rendering> for more details.
(And you can easily use hand-build forms - FormHandler doesn't care.)
(And you can easily use hand-built forms - FormHandler doesn't care.)
The typical application for FormHandler would be in a Catalyst, DBIx::Class,
Template Toolkit web application, but use is not limited to that. FormHandler
Expand Down Expand Up @@ -218,8 +218,8 @@ Examples of creating a form object with new:
],
);
See the model class for more information about the 'item', 'item_id',
'item_class', and schema (for the DBIC model).
See the model class for more information about 'item', 'item_id',
'item_class', and 'schema' (for the DBIC model).
L<HTML::FormHandler::Model::DBIC>.
FormHandler forms are handled in two steps: 1) create with 'new',
Expand Down Expand Up @@ -256,7 +256,7 @@ A non-database form requires only parameters.
schema => $schema, params => $c->req->parameters );
$form->process( params => $c->req->parameters );
This process method returns the 'validated' flag. (C<< $form->validated >>)
This process method returns the 'validated' flag (C<< $form->validated >>).
If it is a database form and the form validates, the database row
will be updated.
Expand Down Expand Up @@ -358,7 +358,7 @@ Returns a hashref of all field values. Useful for non-database forms, or if
you want to update the database yourself. The 'fif' method returns
a hashref with the field names for the keys and the field's 'fif' for the
values; 'value' returns a hashref with the field accessors for the keys, and the
field's 'value' (possibly inflated) for the the values.
field's 'value' (possibly inflated) for the values.
Forms containing arrays to be processed with L<HTML::FormHandler::Field::Repeatable>
will have parameters with dots and numbers, like 'addresses.0.city', while the
Expand Down Expand Up @@ -452,7 +452,7 @@ initially built. It takes the same field name keys as 'update_field_list', plus
foo => { element_class => 'blue' },
}}
The 'all' hash key will apply updates to all fields (conflicting attributes
The 'all' hash key will apply updates to all fields. (Conflicting attributes
in a field definition take precedence.)
The 'by_flag' hash key will apply updates to fields with a particular flag.
Expand Down Expand Up @@ -482,9 +482,8 @@ have to say 'default' for every field).
=head3 active/inactive
A field can be marked 'inactive' and set to active at new or process time;
Then the field name can be specified in the 'active' array, either on 'new',
or on 'process':
A field can be marked 'inactive' and set to active at new or process time
by specifying the field name in the 'active' array:
has_field 'foo' => ( type => 'Text', inactive => 1 );
...
Expand All @@ -502,8 +501,8 @@ time:
$form->process( inactive => ['foo'] );
Fields specified as active/inactive on new will have the form's inactive/active
arrayref cleared and the the field's inactive flag set appropriately, so the
that state will be effective for the life of the form object. Fields specified as
arrayref cleared and the field's inactive flag set appropriately, so that
the state will be effective for the life of the form object. Fields specified as
active/inactive on 'process' will have the field's '_active' flag set for the life
of the request (the _active flag will be cleared when the form is cleared).
Expand Down Expand Up @@ -534,7 +533,7 @@ is the method that returns the fields that are looped through when rendering.
=head3 field($name), subfield($name)
This is the method that is usually called to access a field:
'field' is the method that is usually called to access a field:
my $title = $form->field('title')->value;
[% f = form.field('title') %]
Expand Down Expand Up @@ -579,7 +578,7 @@ default is 'validate_' plus the field name:
If the field name has dots they should be replaced with underscores.
Note that you also provide a coderef which will be a method on the field:
Note that you can also provide a coderef which will be a method on the field:
has_field 'foo' => ( validate_method => \&validate_foo );
Expand Down Expand Up @@ -625,7 +624,7 @@ or in tests. If you add other attributes to your form that are set on
each request, you may need to clear those yourself.
If you do not call the form's 'process' method on a persistent form,
such as in a REST controller's non-POST method or if you only call
such as in a REST controller's non-POST method, or if you only call
process when the form is posted, you will also need to call C<< $form->clear >>.
The 'run' method which returns a result object always performs 'clear', to
Expand Down
22 changes: 11 additions & 11 deletions lib/HTML/FormHandler/Field.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The name of the field with all parents:
=item full_accessor
The field accessor with all parents
The field accessor with all parents.
=item html_name
Expand Down Expand Up @@ -169,7 +169,7 @@ want to use a MakeText language handle. Default is an empty list.
=item add_error
Add an error to the list of errors. Field will be localized
Add an error to the list of errors. Error message will be localized
using '_localize' method.
See also L<HTML::FormHandler::TraitFor::I18N>.
Expand Down Expand Up @@ -243,7 +243,7 @@ attributes, etc.
The slots for the class attributes are arrayrefs; they will coerce a
string into an arrayref.
In addition, these 'wrapping methods' call a hook method in the form class,
'html_attributes' which you can use to customize and localize the various
'html_attributes', which you can use to customize and localize the various
attributes. (Field types: 'element', 'wrapper', 'label')
sub html_attributes {
Expand All @@ -257,7 +257,7 @@ The 'process_attrs' function will also handle an array of strings, such as for t
=head2 tags
A hashref containing flags and string for use in the rendering code.
A hashref containing flags and strings for use in the rendering code.
The value of a tag can be a string, a coderef (accessed as a method on the
field) or a block specified with a percent followed by the blockname
('%blockname').
Expand Down Expand Up @@ -293,8 +293,8 @@ to create a widget template.
Widget types for some of the provided field classes:
Widget : Field classes
---------------:-----------------------------------
Widget : Field classes
-----------------------:---------------------------------
Text : Text, Integer
Checkbox : Checkbox, Boolean
RadioGroup : Select, Multiple, IntRange (etc)
Expand Down Expand Up @@ -334,7 +334,7 @@ For more about widgets, see L<HTML::FormHandler::Manual::Rendering>.
=head2 Defaults
See also the section in L<HTML::FormHandler::Manual::Intro#Defaults>.
See also the documentation on L<HTML::FormHandler::Manual::Intro/Defaults>.
=over
Expand Down Expand Up @@ -406,7 +406,7 @@ the DB model.
Set messages created by FormHandler by setting in the 'messages'
hashref. Some field subclasses have additional settable messages.
required: Error message text added to errors if required field is not present
required: Error message text added to errors if required field is not present.
The default is "Field <field label> is required".
=item range_start
Expand All @@ -420,7 +420,7 @@ does not have 'options'.
The IntRange field uses this range to create a select list
with a range of integers.
In a FormHandler field_list
In a FormHandler field_list:
age => {
type => 'Integer',
Expand Down Expand Up @@ -492,11 +492,11 @@ Deflate to a string format for presenting in HTML.
=item inflate_default_method
Modify the 'default' provided by an 'item' or 'init_object'
Modify the 'default' provided by an 'item' or 'init_object'.
=item deflate_value_method
Modify the value return by C<< $form->value >>.
Modify the value returned by C<< $form->value >>.
=item deflation
Expand Down
2 changes: 1 addition & 1 deletion lib/HTML/FormHandler/Field/Select.pm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Set to the string value of the select label if you want the renderer
to create an empty select value. This only affects rendering - it does
not add an entry to the list of options.
has_field 'fruit' => ( type => 'Select,
has_field 'fruit' => ( type => 'Select',
empty_select => '---Choose a Fruit---' );
=head1 value_when_empty
Expand Down

0 comments on commit 6f3948c

Please sign in to comment.