HTML::Widget 1.09 review

by on

License: Perl Artistic License
File size: 65K
Developer: Sebastian Riedel
0 stars award from

HTML::Widget is a Perl module with HTML Widget And Validation Framework.


use HTML::Widget;

# Create a widget
my $w = HTML::Widget->new('widget')->method('get')->action('/');

# Add a fieldset to contain the elements
my $fs = $w->element( 'Fieldset', 'user' )->legend('User Details');

# Add some elements
$fs->element( 'Textfield', 'age' )->label('Age')->size(3);
$fs->element( 'Textfield', 'name' )->label('Name')->size(60);
$fs->element( 'Submit', 'ok' )->value('OK');

# Add some constraints
$w->constraint( 'Integer', 'age' )->message('No integer.');
$w->constraint( 'Not_Integer', 'name' )->message('Integer.');
$w->constraint( 'All', 'age', 'name' )->message('Missing value.');

# Add some filters

# Process
my $result = $w->process;
my $result = $w->process($query);

# Check validation results
my @valid_fields = $result->valid;
my $is_valid = $result->valid('foo');
my @invalid_fields = $result->have_errors;
my $is_invalid = $result->has_errors('foo');;

#! (read-only)
my $value = $result->param('foo');
my @params = $result->param;

# Catalyst::Request-compatible
my $value = $result->params->{foo};
my @params = keys %{ $result->params };

# Merge widgets (constraints and elements will be appended)

# Embed widgets (as fieldset)

# Get list of elements
my @elements = $widget->get_elements;

# Get list of constraints
my @constraints = $widget->get_constraints;

# Get list of filters
my @filters = $widget->get_filters;

Create easy to maintain HTML widgets!

Everything is optional, use validation only or just generate forms, you can embed and merge them later.

The API was designed similar to other popular modules like Data::FormValidator and FormValidator::Simple, HTML::FillInForm is also built in (and much faster).

This Module is very powerful, don't misuse it as a template system!


HTML::Widget 1.09 keywords