[html-formfu] HTML-FormFu v2.00 - major layout changes

Carl Franks carl at fireartist.com
Fri Apr 11 11:33:11 GMT 2014


Hi all,

A new version of HTML-FormFu has been uploaded and indexed - and should 
appear on (meta)cpan very soon.

Element rendering has been completely rewritten to use a new layout() 
method.
This allows us to easily rearrange and nest the components of each field 
- e.g. label, input, errors, etc.

This is ideal for modifying the generated HTML for integration with your 
JS framework of choice.
(This was also the rational for removing most of the default class names 
in v1.00).
I've been using this for a few months in a project using bootstrap, 
jquery-form, and jquery-validation.

An example, the default layout() is (in yaml)
layout:
   - errors
   - label
   - field
   - comment
   - javascript

Which would output:
<label>LABEL</label>
<input />

To move the field (input or select tag) inside the label tag, simply 
change it to:
layout:
   - errors
   - label:
       - label_text
       - field
   - comment
   - javascript

Which will now output:
<label>
   LABEL
   <input />
</label>

You can also easily add arbitrary tags and attributes too.
See the new "REORDERING FIELD COMPONENTS" documentation in 
HTML::FormFu::Role::Element::Field for further details.

As always, you can use default_args() to set this project-wide under 
Catalyst, or using the new default_args() modifiers introduced in v1.00 
you can easily target specific types of elements.

If you're using render_method('tt'), the template files in "share/" have 
been updated to be fully compatible with these updates.

Cheers,
Carl




More information about the HTML-FormFu mailing list