[Html-widget] HTML-FormFu example xhtml

Carl Franks fireartist at gmail.com
Fri Feb 2 09:24:14 GMT 2007


On 01/02/07, John Napiorkowski <jjn1056 at yahoo.com> wrote:
>
> Carl,
>
> This looks really nice, esp. some of the new stuff you
> mentioned such as being able to easily initialize from
> a config file.  One this that gives me a lot of
> trouble with H::W is that I found it difficult/unclear
> to make custom element classes to make my own custom
> compound elements, or to make simple ready to use
> elements like a drop field with all the USA States
> already prepopulated.  Is making this easier/clearer a
> design goal for your framework?

Yes, but whether it works for you, only you'll be able to answer.
Even in HTML::Widget, it wouldn't be hard to create a sub-class of
Select, which does something like this in the constructor:
    my %states = Geography::USStates::getStates();
    $self->options( map { $_ => $states{$_} } sort keys %states );
Name it as something like HTML::Widget::Element::SelectStates, and it
couldn't be simpler to use.
(It would be even simpler if Geography::USStates returned an /ordered/
list of states.)

> Also what are your plans for constraints and error
> messages.
>
> Another thing I am wondering about are you plans for
> serializing the elements.  H::W is very tightly
> intergrated with each element, so it's not easy to
> create different renderings of a element.  At least I
> found so.  What I am driving at is if the rendering
> system was seperated it could be possible to render a
> form into different styles, like html forms or xforms.
>  But maybe this isn't a goal for you.  Just thinking.

I don't really want to go into too much detail, as I still don't have
anything public I can point to, but it is possible to use accessors to
change which rendering backend is used, either for the whole form, or
just for a single element.

There's an extra step in the process now (but which can be ignored if you want).
$form->result() creates a result object, which can be used / modified
in your templates.
$result->xml() (which stringification does automatically) creates a
render object, which by default stringifies to $render->xml().
This applies to both the form and all elements.

HTML::Element isn't used at all. Everything's now generated in TT templates.
The simplest way of customising a single element would be to change
which template file it uses.
To change the entire layout of an element, set $e->filename().
To change how the label's rendered, set $e->label_filename().
To change just the field's input tag, set $e->field_filename().
...you get the idea :)



More information about the Html-widget mailing list