DESCRIPTION
Field superclass. Must subclass this to be considered a field.
SYNOPSIS
package My::Field;
use Moose;
require Spark::Form::Field;
extends 'Spark::Form::Field';
with 'Spark::Form::Field::Role::Validateable';
with 'Spark::Form::Field::Role::Printable::XHTML';
sub validate {
#validate existence of data
!!shift->value;
}
sub to_xhtml {
#Rather poorly construct an XHTML tag
'<input type="checkbox" value="' . shift-value . '">';
}
Note that you might want to look into HTML::Tiny. Or better still, SparkX::Form::Field::Plugin::StarML.
There are a bunch of prebuilt fields you can actually use in SparkX::Form::BasicFields.
ACCESSORS
name => Str
Name of the field in the data source. Will be slurped on demand. Required at validation time, not at construction time.
form => Spark::Form
Reference to the form it is a member of.
value => Any
Value in the field.
METHODS
human_name
Returns the label if present, else the field name.
SEE ALSO
Spark::Form::Field::Role::Validateable - Fields that can be validated Spark::Form::Field::Role::Printable - Fields that can be printed SparkX::Form::BasicValidators - Set of validators to use creating fields SparkX::Form::BasicFields - Ready to use fields