[Html-widget] HTML::Widget versus RoR helpers

Carl Franks fireartist at gmail.com
Fri Oct 20 14:08:02 GMT 2006


This is a response to Zbigniew's blog entry here:
http://perlalchemy.blogspot.com/
For some reason, I successfully logged in with my google account, yet
still couldn't reply.

A quick summary of zby's entry was that it'd be nice to be able to do this:
[% result.field_html('fieldname, 'textarea', cols, 30, rows, 5) %]
and be able set the element type in the template, rather than the code...

...my reponse :)
You can change a field type at any time with $e->attrs(type => 'textarea')
but that won't effect css classnames, which are type-specific, and of
course you couldn't call $e->rows() unless the element object supports
that.
Which demonstrates the real problem - H-W uses different classes for
different field types.

You could create a super-class wrapper around HTML::Widget which
overrides element and uses some sort of custom element placeholder.
The placeholder should be smart enough that if you just use as_XML(),
it'll delegate to the element type you originally asked for (providing
backward compatability).
You then also override H::W::Result providing your field_html()
method, which can tell the placeholder element to change element type.

The main problem I foresee, is different elements currently have
different methods, corresponding to the valid attributes for different
field types.

Maybe you just have to state that if you want this feature, you can't
use accessors within the perl code, which aren't applicable to all
field types, and that all such settings have to be set in
$result->field_html().

If we can come up with a solution that's back-compatable, there'd be
no problem integrating it into the core

It could also be an option to move the guts out of H::W into a
backend, which different processors, such as this, may use.

Carl



More information about the Html-widget mailing list