[Catalyst] HTML::Widget field_xml() and CSS formatting
Matt S Trout
dbix-class at trout.me.uk
Mon Mar 13 18:14:21 CET 2006
Michele Beltrame wrote:
> 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.
<xsl:template match="label">
<xsl:copy>
<xsl:copy-of select="@*"/>
</xsl:copy>
<xsl:apply-templates/>
</xsl:template>
(and Template::Plugin::XSLT :)
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list