[Catalyst] HTML::Widget field_xml() and CSS formatting

Michele Beltrame mb at italpro.net
Mon Mar 13 17:41:04 CET 2006


Hello!

I am using HTML::Widget to generate my forms and I find that the XML it
generates is quite difficult to skin so that it displays i.e. in a table
like fashion (that is: labels on the left and elements all aligned at a
fixed horizontal location).

I iterate through elements like this (TT2 code):

[% emodify = c.widget_result('emodify') %]
[% FOREACH element IN emodify.elements %]
    [% element.field_xml %]
    [% IF (element.error) %][% element.error_xml %][% END %]
[% END %]

HTML::Widget generates XML such as this for each entry:

<label for="emodify_title" id="emodify_title_label">
  Titolo
  <input class="textfield" id="emodify_title" name="title" type="text"
value="astor" />
</label>

With this XML, using CSS properties such as 'left: 200px' for
"textfield" class actually moves the elements, but they remain
non-aligned if the labels have a different text between each others (and
of course they have). Also using 'position:absolute;' doesn't work as
they are actually positioned but the exit from the document flow,
therefore not allowing the underlying <div> which contains the entire
form to expand automatically in the vertical direction.

A generated XML code such as this would probably do better:

<label for="emodify_title" id="emodify_title_label">
  Titolo
</label>
<input class="textfield" id="emodify_title" name="title" type="text"
value="astor" />

Is there any reason why the XML code isn't generated this way? If so, is
there some way to skin the form table-like via CSS with the current XML
code? I tried - and asked a couple of people as well - but I could come
up to no solution.

Thanks in advance,
Michele.

-- 
Michele Beltrame
http://www.varlogarthas.net/
ICQ# 76660101
Informativa privacy: http://www.italpro.net/em.html



More information about the Catalyst mailing list