HTML::FormFu

HTML Form Creation, Rendering and Validation Framework
Download

HTML::FormFu Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Carl Franks
  • Publisher web site:
  • http://search.cpan.org/~cfranks/

HTML::FormFu Tags


HTML::FormFu Description

HTML Form Creation, Rendering and Validation Framework HTML::FormFu is a HTML form creation, rendering and validation framework written in Perl.BETA SOFTWAREThere may be API changes required before the 1.0 release. Any incompatible changes will first be discussed on the mailing list. See "DEPRECATION POLICY" for further details.Work is still needed on the documentation, if you come across any errors or find something confusing, please give feedback via the mailing list.SYNOPSISNote: These examples make use of HTML::FormFu::Model::DBIC. As of HTML::FormFu v02.005, the HTML::FormFu::Model::DBIC module is not bundled with HTML::FormFu and is available in a stand-alone distribution. use HTML::FormFu; my $form = HTML::FormFu->new; $form->load_config_file('form.yml'); $form->process( $cgi_query ); if ( $form->submitted_and_valid ) { # do something with $form->params } else { # display the form $template->param( form => $form ); }If you're using Catalyst, a more suitable example might be: package MyApp::Controller::User; use strict; use base 'Catalyst::Controller::HTML::FormFu'; sub user : Chained CaptureArgs(1) { my ( $self, $c, $id ) = @_; my $rs = $c->model('Schema')->resultset('User'); $c->stash->{user} = $rs->find( $id ); return; } sub edit : Chained('user') Args(0) FormConfig { my ( $self, $c ) = @_; my $form = $c->stash->{form}; my $user = $c->stash->{user}; if ( $form->submitted_and_valid ) { $form->model->update( $user ); $c->res->redirect( $c->uri_for( "/user/$id" ) ); return; } $form->model->default_values( $user ) if ! $form->submitted; }Note: Because "process" is automatically called for you by the Catalyst controller; if you make any modifications to the form within your action method, such as adding or changing elements, adding constraints, etc; you must call "process" again yourself before using "submitted_and_valid", any of the methods listed under "SUBMITTED FORM VALUES AND ERRORS" or "MODIFYING A SUBMITTED FORM", or rendering the form.Here's an example of a config file to create a basic login form (all examples here are YAML, but you can use any format supported by Config::Any), you can also create forms directly in your perl code, rather than using an external config file. --- action: /login indicator: submit auto_fieldset: 1 elements: - type: Text name: user constraints: - Required - type: Password name: pass constraints: - Required - type: Submit name: submit constraints: - SingleValueHTML::FormFu is a HTML form framework which aims to be as easy as possible to use for basic web forms, but with the power and flexibility to do anything else you might want to do (as long as it involves forms).You can configure almost any part of formfu's behaviour and output. By default formfu renders "XHTML 1.0 Strict" compliant markup, with as little extra markup as possible, but with sufficient CSS class names to allow for a wide-range of output styles to be generated by changing only the CSS.All methods listed below (except "new") can either be called as a normal method on your $form object, or as an option in your config file. Examples will mainly be shown in YAML config syntax.This documentation follows the convention that method arguments surrounded by square brackets [] are optional, and all other arguments are required. Requirements: · Perl


HTML::FormFu Related Software