[html-formfu] I need the most basic tutorial

Bart Lateur bart.lateur at telenet.be
Wed May 12 08:16:59 GMT 2010


Though I've worked with similar modules in the past, I find it very hard
to wrap my head around the very basics behind HTML::FormFu. Even the
tutorials I can find on the web (either by external authors, or included
with the module on CPAN) start at a too high level.

What I want is a very basic example on how to make a basic CRUD
interface, in a minimal CGI app. I want to do the next thing, *without*
use of *any* external module: no DBIx::Class, no Class::DBI, and
definitely no Catalyst! I want to learn exactly how FormFu is supposed
to work without all this extra bagage.

* Data from database: the interface to the DB is external

    %data = ( id => 1234, foo => "one", bar => "two", yn => 1 );

* Basic form: 

    auto_fieldset: 1
    elements:
      - type: Hidden
        name: id
      - type: Text
        label: "Foo:"
        name: foo
      - type: Text
        label: "Bar:"
        name: bar
      - type: Checkbox
        label: "boolean:"
        name: yn
        default: 0
      - type: Submit
        value: "Update"


I'd like to use the same form script for showing the data to the user
and for getting the new values from the user. Business as usual, I would
say.

My questions:

  * How do I put the data from the hash \%data into the form? Should I
use default_values for that? Or something else? process?
  * I assume I must "process" the input to put the updated data into the
form?
  * Apparently a partially updated form drops every default value? Is
that correct behaviour?
  * How do I get the data back out of the processed form, in order to
update the DB? I'm especially worried about that boolean
  * How do I replace the Checkbox with a pair of radio buttons? Just
replacing "Checkbox" with "Radio" produces an unusable result, and the
docs for  HTML::FormFu::Element::Checkbox are useless.
  * How does basic validation fit in? How do I flag an error, for
example if text in a field is too long, or contains illegal characters?
  * Where does validation in Javascript, i.e; without round trip to the
server, fit in?
  * What's the best way to have a single form for both "add" and "edit",
depending on whether "id" is set or not?
  * How do you change the way items of the form are rendered, for
example, what if I prefer the form to be in a 2 column table, labels in
column 1, fields in column 2?
  * What's the best practice to flag to a user a field is required? How
does it fit into FormFu?

There's probably more, but nothing I can think of right now...

Thank you for you're patients.

-- 
	Bart Lateur
	bart.lateur at telenet.be



More information about the HTML-FormFu mailing list