CGI::AutoForm

Automated abstraction of HTML forms from a data source
Download

CGI::AutoForm Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Reed Sandberg
  • Publisher web site:
  • http://search.cpan.org/~rsandberg/

CGI::AutoForm Tags


CGI::AutoForm Description

Automated abstraction of HTML forms from a data source CGI::AutoForm is an automated abstraction of HTML forms from a data source.There are many CGI form abstractions available, (e.g. CGI.pm). A unique and powerful advantage with this abstraction is that it can be tied closely with a database schema. Each group of fields in the form can represent a database table (or view) and the table/column properties and constraints are automagically discovered so your DBA can make DDL changes that will be immediately reflected in the HTML forms (no duplication of the data dictionary in your code).All user/operator input is checked tightly against database constraints and there is built-in magic to provide convenient select lists, etc, and to enforce a discreet set of valid values against unique/primary keys in lookup tables (see Select lists & ID masking). This means referential integrity even for MySQL. Metadata in MySQL's SET and ENUM types are also supported. This also gives the operator a chance to correct mistakes with helpful hints instead of just getting a meaningless db error code.This design allows you to get secure, database-driven web apps up and running is as little as a few hours (see Cruddy! for an implementation http://www.thesmbexchange.com/cruddy/index.html). This is made possible with the help of the DBIx::IO abstraction, please refer to it for further details.Another advantage this abstraction provides is the separation of presentation and style using style sheets and having human-friendly presentation attributes stored in a database table that can be managed by non-engineers.Typical CGI apps are characterized by collecting, updating, reporting and formatting data using forms and tables. Form creation and processing can be divided into the following tasks:1) Deciding what data to collect in order to perform the desired function.2) Deciding how the operator will convey the desired information (input fields, checkboxes etc).3) Form layout.4) Imposing integrity constraints on the collected data.5) Presentation and style.6) Directing the collected data.This class allows (but doesn't force) form elements and constraints to be defined in a database. This way, the definitions are organized in a central repository, so they can be managed in a shared environment separate from the code. Vanilla HTML is generated and several HTML classes are used so that presentation and style can be dictated with style sheets (again separate from the code). For flexibility, methods are given to modify form definitions and layout programmatically as well.SYNOPSIS use CGI::AutoForm; $form = new CGI::AutoForm($dbh,$form_name); $form->action($action_url); $form->add_group($CGI::AutoForm::EDIT_GROUP,$table_name); $form->add_record($current_record); $form_html = $self->prepare(); # insert $form_html into the BODY section of an (X)HTML document via a template $group = $form->group_by_name($group_name); $bool = $form->validate_query($query,$callback); $records = $form->format_query($query); $form_copy = $form->clone(); $form->reset_group(); # # an example of customizing a data group's fields... # $rv = $form->add_group($CGI::AutoForm::INSERT_GROUP,undef,'Vote For Your Favorite Artist','ARTIST_VOTE'); $fields = $form->db_fields('ARTIST',$CGI::AutoForm::INSERT_GROUP); $form->push_field($fields->{ARTIST_NAME}); $form->add_field( { FIELD_NAME => 'VOTE', INPUT_CONTROL_TYPE => 'RADIO', REQUIRED => 'Y', HEADING => 'Vote', DATATYPE => 'CHAR', INSERTABLE => 'Y', }, ); $form_html = $self->prepare( { 'ARTIST_VOTE.ARTIST_NAME' => 'Nonpoint', 'ARTIST_VOTE.VOTE' => 4 } ); Requirements: · Perl


CGI::AutoForm Related Software