Skip to content

Commit

Permalink
documentation typos
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Mar 8, 2012
1 parent c672e4c commit 12e678b
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 23 deletions.
21 changes: 16 additions & 5 deletions lib/HTML/FormHandler.pm
Expand Up @@ -28,7 +28,7 @@ our $VERSION = '0.40001';

=head1 SYNOPSIS
See the manual at L< HTML::FormHandler::Manual >.
See the manual at L<HTML::FormHandler::Manual>.
use HTML::FormHandler; # or a custom form: use MyApp::Form::User;
my $form = HTML::FormHandler->new( .... );
Expand Down Expand Up @@ -213,6 +213,7 @@ Examples of creating a form object with new:
field_list => [
name => 'Text',
active => 'Boolean',
submit_btn => 'Submit',
],
);
Expand All @@ -228,9 +229,10 @@ fields are built at construction time.
If you want to update field attributes on the 'process' call, you can
use an 'update_field_list' or 'defaults' hashref attribute , or subclass
update_fields in your form. The 'defaults' attribute will update only
the 'default' attribute in the field. The 'update_field_list' hashref
can be used to set any field attribute:
update_fields in your form. The 'update_field_list' hashref can be used
to set any field attribute. The 'defaults' hashref will update only
the 'default' attribute in the field. (There are a lot of ways to
set defaults. See L<HTML::FormHandler::Manual::Defaults>.)
$form->process( defaults => { foo => 'foo_def', bar => 'bar_def' } );
$form->process( update_field_list => { foo => { label => 'New Label' } });
Expand Down Expand Up @@ -368,7 +370,8 @@ Fields are declared with a number of attributes which are defined in
L<HTML::FormHandler::Field>. If you want additional attributes you can
define your own field classes (or apply a role to a field class - see
L<HTML::FormHandler::Manual::Cookbook>). The field 'type' (used in field
definitions) is the short class name of the field class.
definitions) is the short class name of the field class, used when
searching the 'field_name_space' for the field class.
=head3 has_field
Expand All @@ -393,6 +396,10 @@ alternative to 'has_field' in small, dynamic forms to create fields.
field_two => 'Text,
]
The field_list array takes elements which are either a field_name key
pointing to a 'type' string or a field_name key pointing to a
hashref of field attributes. You can also provide an array of
hashref elements with the name as an additional attribute.
The field list can be set inside a form class, when you want to
add fields to the form depending on some other state, although
you can also create all the fields and set some of them inactive.
Expand Down Expand Up @@ -556,6 +563,10 @@ 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:
has_field 'foo' => ( validate_method => \&validate_foo );
=head3 validate
This is a form method that is useful for cross checking values after they have
Expand Down
2 changes: 1 addition & 1 deletion lib/HTML/FormHandler/Manual.pod
Expand Up @@ -48,7 +48,7 @@ Issues and setup for database forms.

Builds on the Catalyst tutorial. Step-by-step guide.

=head2 L<HMLT::FormHandler::Manual::Testing>
=head2 L<HTML::FormHandler::Manual::Testing>

Test your forms

Expand Down
2 changes: 1 addition & 1 deletion lib/HTML/FormHandler/Manual/Database.pod
Expand Up @@ -54,7 +54,7 @@ relationship. The 'value' of the field is derived from the 'has_many'
part of the relationship.

The primary key is used for the 'id' of the select. The 'label' column of
the select is assumed to be 'name'. If the label columns has a different
the select is assumed to be 'name'. If the label column has a different
name, it must be specified with 'label_column'.

Pertinent attributes:
Expand Down
4 changes: 2 additions & 2 deletions lib/HTML/FormHandler/Manual/Defaults.pod
Expand Up @@ -71,8 +71,8 @@ while the 'init_object' uses "structured" data:

my $defaults = {
model => 'standard',
opts.color => 'Red',
opts.size => 'Big',
'opts.color' => 'Red',
'opts.size' => 'Big',
};
my $init_object => {
model => 'standard',
Expand Down
8 changes: 4 additions & 4 deletions lib/HTML/FormHandler/Manual/Errors.pod
@@ -1,5 +1,5 @@
package HTML::FormHandler::Manual::Errors;
# ABSTRACT: FormHandler use recipes
# ABSTRACT: FormHandler error methods

=head1 SYNOPSIS

Expand Down Expand Up @@ -71,7 +71,7 @@ Add a non-localized error to the form.

=back 4

=head2 Field methods
=head1 Field methods

The most common error method is probably 'add_error', which you
use in the validation process.
Expand All @@ -87,7 +87,7 @@ use in the validation process.

=item errors

Returns an array of errors strings;
Returns an array of error strings;

=item has_errors

Expand All @@ -110,7 +110,7 @@ of fields with errors.

=back 4

=head2 Result methods
=head1 Result methods

The input, value, and error attributes are actually stored in the
result objects. Although most of the methods are delegated to the
Expand Down
5 changes: 3 additions & 2 deletions lib/HTML/FormHandler/Manual/Fields.pod
Expand Up @@ -73,14 +73,14 @@ will be searched for fields.
has '+field_name_space' => ( default => 'MyApp::Form::Field' );
has_field 'name' => ( type => 'Text' ); # HTML::FormHandler::Field::Text
has_field 'name' => ( type => '+My::FieldType' ); # My::Fieldtype
has_field 'foo' => ( type => +Foo' ); # MyApp::Form::Field::Foo
has_field 'foo' => ( type => '+Foo' ); # MyApp::Form::Field::Foo
or
has_field 'foo' => ( type => 'Foo' ); # MyApp::Form::Field::Foo


The most basic type is "Text", which is usually a 'text' HTML element and
a string data type. (If the type of a field is not specified, it will be set to
'Text'.) A "Select" field type is an HTML form element, and validates against
'Text'.) A "Select" field type is a HTML select element, and validates against
the list of values provided in the 'options'. A "Multiple" type is like "Select"
but it allows selecting more than one value at a time.

Expand Down Expand Up @@ -131,6 +131,7 @@ If the field's value will be an object instead of a simple scalar, such
as a DateTime and you want to use the transformed value to fill in the
form, then you will also need a deflation or field class 'deflate' method
to reformat the object into a form suitable for an HTML form field.
See L<HTML::FormHandler::Manual::InflationDeflation> for more info.

Some custom fields might only require setting certain attributes to
defaults, such as the L<HTML::FormHandler::Field::Hour> field, which
Expand Down
20 changes: 19 additions & 1 deletion lib/HTML/FormHandler/Manual/Intro.pod
Expand Up @@ -216,14 +216,32 @@ on fields.
You can use 'has_field' and 'has_block' in Moose roles:

package MyApp::Form::Role::Address;
use HTML::FormHandler::Moose;
use HTML::FormHandler::Moose::Role;

has_field 'foo';
has_block 'bar';

Your forms can inherit from base classes that set common application
defaults. You can override field definitions with '+'.

You can create 'compound' fields and include them in a form:

package MyApp::Form::Field::Complex;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Field::Compound';
has_field 'field1' => ( validate_method => \&validate_field1 );
has_field 'field2' => ( type => 'Select',
options_method => \&options_field2 );
sub validate_field1 { ... }
sub options_field2 { ... }
...
package MyApp::Form::Complex;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
has '+field_name_space' => ( sub => {['MyApp::Form::Field']} );
has_field 'compound1' => ( type => 'Complex' );
has_field 'compound2' => ( type => 'Complex' );

=head2 Testing

It's much easier to write unit tests for FormHandler forms than for
Expand Down
4 changes: 2 additions & 2 deletions lib/HTML/FormHandler/Manual/Rendering.pod
Expand Up @@ -9,7 +9,7 @@ Rendering can be done in many different ways, from forms rendered entirely in
templates with no information from FormHandler (except possibly the fill-in-the-form
values) to forms that are completely rendered by FormHandler.

=head2 DESCRIPTION
=head1 DESCRIPTION

For most situations, something in between hand-built and completely generated
will probably be the best solution. For admin forms that don't need a lot of
Expand Down Expand Up @@ -473,7 +473,7 @@ Setting it for a field will just be for that field.
-- or --
has_field 'foo' => ( render_filter => sub { ... } );

The filter is called in Render::Simple in the widgets with
The filter is called in Render::Simple and in the widgets with
C<< $self->html_filter( $fif ) or $field->html_filter( $fif ) >>.

If you want to turn off the filter for a particular field, you can set it
Expand Down
2 changes: 1 addition & 1 deletion lib/HTML/FormHandler/Manual/Templates.pod
Expand Up @@ -42,7 +42,7 @@ There is also a template which combines the template rendering code into
one file, 'share/templates/form/form_in_one.tt'. You can copy this template
into your own TT directories, perhaps as form.tt, and then specify it in
as the template for your Catalyst actions. You can customize it by adding
additional widget and widget_wrapper block, and then setting those in your
additional widget and widget_wrapper blocks, and then setting those in your
field definitions.

Note that widget names usually are camelcased, like the Moose roles that
Expand Down
12 changes: 8 additions & 4 deletions lib/HTML/FormHandler/Manual/Validation.pod
Expand Up @@ -36,7 +36,7 @@ performed. The form's 'validate' method, however, will always be called.

Starting and ending range for number fields.

=head1 unique
=head2 unique

Attribute used by the DBIC model to check for uniqueness.

Expand All @@ -50,7 +50,9 @@ You can provide a validation method for a field by setting a coderef with
has_field 'fox' => ( validate_method => \&check_fox );
sub check_fox {
my $self = shift; # self is the fox field
.....
unless( $self->value eq .... ) {
$self->add_error('....');
}
}

=head2 validate_<field_name>
Expand All @@ -60,7 +62,9 @@ If you provide a 'validate_<field_name>' method it will be automatically used.
has_field 'cat';
sub validate_cat {
my ( $self, $field ) = @_; # self is the form
....
unless ( $field->value eq ... ) {
$field->add_error( '...' );
}
}

If the field name has periods in it, they should be replaced with underscores.
Expand Down Expand Up @@ -117,7 +121,7 @@ on inflation and deflation.

Moose types can be used to do both constraints and transformations. If a coercion
exists it will be applied, resulting in a transformation. After coercing, the
result is checked. You can use type constraints form L<MooseX::Types>>
result is checked. You can use type constraints from L<MooseX::Types>>
libraries or defined using L<Moose::Util::TypeConstraints>.

FormHandler supplies a library of Moose types in L<HTML::FormHandler::Types>.
Expand Down

0 comments on commit 12e678b

Please sign in to comment.