[ANNOUNCE] Class::DBI::FormBuilder

[prev] [thread] [next] [Date index for 2005/06/09]

From: David Baird
Subject: [ANNOUNCE] Class::DBI::FormBuilder
Date: 22:03 on 09 Jun 2005
I've just uploaded Class::DBI::FormBuilder to the CPAN. From the POD -

=head1 NAME

Class::DBI::FormBuilder - Class::DBI/CGI::FormBuilder integration

=head1 SYNOPSIS


    package Film;
    use strict;
    use warnings;
   
    use base 'Class::DBI';
    use Class::DBI::FormBuilder;
   
    Film->form_builder_defaults( { smartness => 3 } );
   
    # These fields must always be submitted for create/update routines
    Film->columns( Required => qw( foo bar ) );
   
    # same thing, differently
    # Film->form_builder_defaults->{required} = [ qw( foo bar ) ];
   
   
    # In a nearby piece of code...
   
    my $film = Film->retrieve( $id );
    print $film->as_form( params => $q )->render;   # or $r if mod_perl
   
    # For a search app:   
    my $search_form = Film->search_form;            # as_form plus a few 
tweaks
   
   
    # A fairly complete app:
   
    my $form = Film->as_form( params => $q );       # or $r if mod_perl
   
    if ( $form->submitted and $form->validate )
    {
        # whatever you need:
       
        my $obj = Film->create_from_form( $form );
        my $obj = Film->update_from_form( $form );             
        my $obj = Film->update_or_create_from_form( $form );   
        my $obj = Film->retrieve_from_form( $form );
       
        my $iter = Film->search_from_form( $form );
        my $iter = Film->search_like_from_form( $form );
        my $iter = Film->search_where_from_form( $form );
       
        my $obj = Film->find_or_create_from_form( $form );
        my $obj = Film->retrieve_or_create_from_form( $form );
       
        print $form->confirm;
    }
    else
    {
        print $form->render;
    }
   
    # See CGI::FormBuilder docs and website for lots more information.
   
=head1 DESCRIPTION

This module creates a L<CGI::FormBuilder|CGI::FormBuilder> form from a 
CDBI class or object. If
from an object, it populates the form fields with the object's values.

Column metadata and CDBI relationships are analyzed and the fields of 
the form are modified accordingly.
For instance, MySQL C<enum> and C<set> columns are configured as 
C<select>, <radiobutton> or
C<checkbox> widgets as appropriate, and appropriate widgets are built 
for C<has_a>, C<has_many>
and C<might_have> relationships. Further relationships can be handled by 
subclassing.

Greetings,

d.

[ANNOUNCE] Class::DBI::FormBuilder
David Baird 22:03 on 09 Jun 2005

Generated at 16:37 on 28 Jul 2005 by mariachi v0.52