NAME

Form::Sensible::Field::Number - A Numeric field type.

SYNOPSIS

    use Form::Sensible::Field::Number;
    
    my $object = Form::Sensible::Field::Number->new( 
                                                        integer_only => 1,
                                                        lower_bound => 10,
                                                        upper_bound => 100,
                                                        step => 5,
                                                    );

    $object->do_stuff();

DESCRIPTION

The number field type is one of the more advanced field types in Form::Sensible. It has a number of features for dealing specifically with numbers. It can be set to have a lower and upper bound, allowing validation to ensure that the value selected is within a range. It can also be set to have a 'step', which provides a constraint to what values are valid between the upper and lower bounds. It can also be made to accept integers only, or fractional values.

Finally, it can be rendered in a number of ways including select boxes, drop downs or even ranged-sliders if your renderer supports it.

ATTRIBUTES

integer_only

True/false value indicating whether this field is able to accept fractional values.

lower_bound

Lower bound of valid values for the field.

upper_bound

Upper bound of valid values for the field.

step

When step is provided, the value provided must be a multiple of step in order to be valid.

METHODS

validate

Validates the field against the numeric constraints set for the field.

get_potential_values($step, $lower_bound, $upper_bound)

Returns an array containing all the valid values between the upper and lower bound. Used internally to the number field.

in_step($value, $step)

Returns true if $value lies on a $step boundary. Otherwise returns false.

The following two methods allow Number fields to be treated like Select Fields for rendering purposes.

options

An array ref containing the allowed options. Each option is represented as a hash containing a name element and a value element for the given option.

accepts_multiple

On a Select field, this defines whether a the field can have multiple values. For a Number field, only one value is allowed, so this always returns false.

AUTHOR

Jay Kuri - <jayk@cpan.org>

SPONSORED BY

Ionzero LLC. http://ionzero.com/

SEE ALSO

Form::Sensible

LICENSE

Copyright 2009 by Jay Kuri <jayk@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.