Data::Form::Elements - a wrapper API for Data::FormValidator and a module for providing elemental access to the fields of a form, from a generic perspective. The form in question does not need to be an HTML form. Basically, if Data::FormValidator can use it as a form, so can we. Version 0.01 A quick example of using this module for a login form: use Data::Form::Elements; my $form = Data::Form::Elements->new(); # add a couple elements $form->add_element( "username", { required => 1, errmsg => "Please provide your username." } ); $form->add_element( "password", { required => 1, errmsg => "Please provide your password." } ); ... $form->validate( %ARGS ); if ( $form->is_valid() ) { # continue logging on ... }

new()
Simple constructor.

add_element()
Add an element to the form object. A full form element looks like this $form->add_element( "sort_position" , { required => 0, valid => 0, value => '', errmsg => 'Please choose where this section will show up on the list.', constratints => qr/^\d+$/, invmsg => 'Only numbers are allowed for this field. Please use the dropdown to select the position for this section.' }); By default, only the name (key) is required. the required element will default to 0 if it is not specified. If required is set to 1 and the errmsg has not been initialized, it will also be set to a default.

params()
Returns a list of the elements in this form.

dump_form()
use Data::Dumper to help debug a form.

dump_validator()
use Data::Dumper to help debug a form's underlying Data::FormValidator.

validate()
Takes a hash of values for the form elements and validates them against the rules you have set up. Example: $form->validate( %ARGS ); if ( $form->is_valid() ) { # continue processing form... }

is_valid()
Returns true/false.

param()
Getter/Setter methods for setting an individual form element. Example: # getter print $form->param("username"); # setter $form->param("username", "jason"); TODO: make accessors like Class::DBI so you will be able to do $form->username(); or $form->username("jason");

message()
returns the error or invalid message for a form element, if there is one. Returns undef if no message exists. jason gessner, "<jason@multiply.o>" Please report any bugs or feature requests to "bug-testing@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. Copyright 2004 me, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.