A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Perl Webform CRUD

I have a dream that I can use Perl to build a webpage that allows me to view what's in a database table, and to add new rows to it, *without specifying any of the fields or constraints*!

Okay, maybe I might want to map column names to user-friendly labels, or add additional constraints to the fields (e.g. email address), but that's it.

I particularly don't want to duplicate the constraints which I've already programmed into the database table once. i.e. The form should only validate input data against the database schema, and feed back appropriate errors/warnings.
I don't want to have to duplicate the column list in the database, by defining all the form fields in a configuration file.
And I definitely don't want to have to write any HTML at all.
I must be able to completely integrate the system into my own framework.

UPDATE:
Perhaps if I don't specify pretty names for the columns, or their order, then I end up with a database management tool like phpMyAdmin. This means configuration of the fields is necessary for a real web app.
Probably the same goes for HTML output - its purpose is to lay out the page, so I am required to list the fields there as well.
But I really dislike having to edit all three files (schema, config, and template) when I add a new database column.

Possible modules for DBIx:
  • Catalyst::Manual::Tutorial::09_AdvancedCRUD::09_FormFu - Handles the database part automagically. We define the webform fields, along with any additional constraints and helpful validation features in a configuration file. The fields must also be defined in the template. However, error messages defined in the config file will appear automatically in the right place in the form (with a little help from CSS).
    • HTML::FormFu - This seems to be the best thing.
    • Catalyst::Model::HTML::FormFu (deprecated)
    • Catalyst::Model::FormFu - "Speedier interface to HTML::FormFu for Catalyst"
  • HTML::FormFu::Model::DBIC - "Integrate HTML::FormFu with DBIx::Class". The form fields must be specified in config, and they must match the DBIx class schema.
  • Catalyst::Plugin::FormBuilder - "merges the functionality of CGI::FormBuilder with Catalyst and Template Toolkit" - ?
    • Catalyst::Controller::FormBuilder
  • Catalyst::Example::InstantCRUD - contains DBIx::Class::InstantCRUD. Presumably this is meant to be a database admin tool. See instantcrud.pl
  • Catalyst::Plugin::CRUD::DBIC - "CRUD plugin for DBIx::Class". Looks promising, but the fields also must be listed in an HTML template.
  • DBIx::HTMLinterface
  • DBIx::HTMLView 
  • DBIx::Class::HTMLWidget
  • DBIx::Class::FormTools
  • Catalyst::Helper::Controller::Scaffold
  • Catalyst::Enzyme 
For CGI:
  • CGI::Application::Plugin::BREAD 
  • CGI::Prototype 
  • CGI::FormBuilder - "I hate generating and processing forms" (the author). But do we still have to specify the form fields using Perl code?
See also:
Modules I've actually seen in use:

  • HTML::FormHandler - example
  • Data::FormValidator