[Html-widget] Rails-like form helpers - RFC for a new module

John Napiorkowski jjn1056 at yahoo.com
Mon Sep 25 00:37:41 CEST 2006


--- Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:

> Dear all,
> 
> In the new InstantCRUD I decided to take out the
> code for html forms
> generation and make a separate module for it.  After
> reading 'Rails-like
> form helpers' thread I think that this module might
> find a more general use.
> I would like to ask you what intefrace would you
> propose for it.
> 
> It can build the HTML::Widgets based on some config
> and data from the
> database and then can also save the data from the
> widget to the database.
> The config part is more complicated than it could be
> because the info about
> many-to-many relations is not available from the
> schema so you need to
> specify it in the config.  Since it is already there
> I've added also the
> stringification to it - as it is a bit cleaner to
> have it here in the
> interface part than overload stringification in the
> database schema
> definition.
> 
> The current interface is composed of just two
> functions:
> 
>
Catalyst::Example::InstantCRUD::Widget->make_widget($interface_config,
> $class, $schema, $item);
> 
> $interface_config is a hash containing info about
> all db classes and how to
> wigetify them, $class is the db class, $schema is
> DBIC schema and $item is
> the db row to populate values in the form - its
> optional.
> 
>
Catalyst::Example::InstantCRUD::Widget->populate_db($result,
> $item);
> 
> $result is HTML::Widget::Result and $item is the db
> row to be updated
> 
> So my question is do you think it deserves to be
> taken out from InstantCRUD
> and then what name would you propose for it?  How
> would you design the API?

I personally like the idea of having a config file for
this.  One of the things that has really worked for me
with Formbuilding is that option to use a yaml
configuration file to build forms.  I didn't
personally like building the forms in the controller,
it really seems like a view thing to me, and
forwarding to a view to build the form and then to
Template Toolkit seemed really like a lot of extra
work.

With formbuilding I can put the config file in with
the *.tt files and it seems really neat and ordered to
me.

Other things I'd like is an easier way to have the
forms and other elements hook back to catalyst
controllers.  I've really liked the JSF idea of having
the template language be more than a renderer.  Makes
developing AJAX stuff easier.

So it would be very cool if instead of exposing
information to the template system you would expose
objects with callbacks to controllers.  However to get
this to work right we really need a better subrequest
system.  I've been playing with the subrequest plugin
from Trunk just to get the idea of how this all works
but haven't made so much progress in understanding it
all :)

Right now for my portal like system I'm just creating
objects that do dumb LWP requests to a controller.  It
works but feels very crude.

--john

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Html-widget mailing list