Why not adopt me?
NAME
Maypole::FormBuilder - CGI::FormBuilder support in Maypole
SYNOPSIS
use Maypole::Application qw( FormBuilder QuickTable );
BeerFB->config->model( 'Maypole::FormBuilder::Model' );
DESCRIPTION
Maypole provides a great framework for simplifying the interaction between a UI and a database. But it provides very little support for simplifying the interface itself. Programmers are left to construct each form, widget by widget, using modules that don't support important form use cases, such as what to do when a form submits nothing for an empty field.
CGI::FormBuilder already supports this and many, many other forms use cases. And it provides validation methods, multiform support, and automatically generated Javascript validation code. And plenty more.
This distribution uses Class::DBI::FormBuilder to generate the metadata required to automatically build FormBuilder forms from CDBI classes and objects.
The distribution includes:
- Maypole::FormBuilder
-
Introductory documentation only.
- Maypole::Plugin::FormBuilder
-
as_form
,search_form
andas_forms
methods for the Maypole request object. - Maypole::FormBuilder::Model
-
A model class based on Class::DBI. Note that this model does not inherit from Maypole::Model::CDBI.
- Maypole::FormBuilder::Model::Base
-
Model methods that do not depend on the CDBI backend. Models based on a different persistence layer may wish to inherit from this class.
- templates
-
A new set of templates for the Beer database. These are considerably simpler than the BeerDB templates.
templates-mason Mason templates templates-tt TT templates, donated by Ron McClain
Note that the templates also need Maypole::Plugin::QuickTable.
Also note, TT users must bless an object called
mclass
into$request->model_class
and add it to the template vars inadditional_data()
. This is to makemoniker
work, which will always returnProxy
if if you do[% mclass = Class(request.model_class) %]
becauseClass
creates a Proxy object around the model class.
Random notes
If you build a form, and it has no 'name' or 'id' defined, you have probably called as_form
on a CDBI class or object, rather than on the Maypole request object. I often do this when building a form for a different object or class from that represented in the request. Use the 'entity' argument to Maypole::Plugin::FormBuilder::as_form() to do this.
AUTHOR
David Baird, <cpan@riverside-cms.co.uk>
BUGS
Edit and update actions from the editable list template are broken.
After creating or editing an object, if the return is to a list template, need to ensure the appropriate page is set. Or just go back to the original workflow and display the view
template instead.
The development version of Class::DBI::Plugin::Pager (which is the version I have installed) has a bug, so I haven't been able to test using it via the <BeerFB-
config->pager_class>> setting.
Please report any bugs or feature requests to bug-maypole-formbuilder@rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Maypole-FormBuilder. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
TODO
Most links from the editlist
template return the user to the list
template, rather than staying in the editlist
view.
COPYRIGHT & LICENSE
Copyright 2005 David Baird, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.