Chloro::Field - A field in a form
This class represents a field in a form.
This class has the following methods:
You'll probably make fields by using the
field() subroutine exported by Chloro,
but you can make one using this constructor.
The constructor accepts the following parameters:
The name of the field. This is required.
A more friendly version of the name.
This defaults to the same value as
This value will be used when generating error messages for this field.
Just like with Moose attributes, an unknown name is treated as a class name.
The default value for the field. Like Moose attributes, this can either be a non-reference value of a subroutine reference.
A subroutine reference will be called as a method on the field object, and will receive two additional arguments.
The first argument is the parameter passed to the
The second is the prefix for the field, if it is part of a group.
A boolean indicating whether the field is required. Defaults to false.
A boolean indicating whether the field contains sensitive data. Defaults to false.
This is an optional method on the field's form that will be used to extract this field's value.
The extractor is expected to return a two element list. The first should be the name of the field in the form, the second is the value.
This is an optional method on the field's form that will be used to validate this field's value.
The name as passed to the constructor.
A more friendly name,
which defaults to the same value as
This returns a Moose::Meta::TypeConstraint object,
based on the value passed to the constructor in the
The default, as passed to the constructor, if any.
Returns a boolean indicating whether the field is required.
Returns a boolean indicating whether the field contains sensitive data.
Given the user-submitted parameters and an optional prefix, this method returns a default value for the field. If the default is a subroutine reference, that reference will be called with the parameters passed to this method.
Returns a data structure representing the field definition. This exists primarily for testing.
This class consumes the Chloro::Role::FormComponent role.
Dave Rolsky <firstname.lastname@example.org>
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)