[html-formfu] Using TT directives inside a rendered form

Kahlil Hodgson kahlil.hodgson at dealmax.com.au
Thu Aug 27 06:50:44 GMT 2009


Hi,

Thought I might post a little tip for C::C::H::FF usage that solves a
problem that I was going to ask the list about.

If you need to add some (potentially complex) content inside your form
that does not really have anything to do with the form processing
(i.e. you just want it there for exposition) consider passing it off to  TT.

For example, one of my forms has the following element buried deep in
the tree:

    {
         type        => 'Block'
         id          => 'note',
         content_xml => '[% PROCESS note %]',
    },

(yes I use Perl rather than YAML for my form definitions)

Then in my template I have:

    [% BLOCK note %]
    ... some complex content built from TT directives and
        data provided by controller ...
    [% END %]

    [% form | eval %]

The alternatives seem to involve some ugly form manipulation inside the
controller, just to do something that is really presentation based,
or some nasty CSS to push the note inside the form.  This approach helps
to maintain the separation of concerns and doesn't trash the pages
accessibility.

Cheers!

Kal

-- 
Kahlil (Kal) Hodgson                       GPG: C37B01F4
Head of Technology                         (m) +61 (0) 4 2573 0382
DealMax Pty Ltd                            (w) +61 (0) 3 9008 5281

Suite 1005
401 Docklands Drive
Docklands VIC 3008 Australia

"All parts should go together without forcing.  You must remember that
the parts you are reassembling were disassembled by you.  Therefore,
if you can't get them together again, there must be a reason.  By all
means, do not use a hammer."  -- IBM maintenance manual, 1925





More information about the HTML-FormFu mailing list