[Html-widget] Rails-like form helpers - RFC for a new module
Zbigniew Lukasiak
zzbbyy at gmail.com
Mon Oct 2 15:12:44 CEST 2006
I've uploaded a first version to
http://zby.aster.net.pl/HTML-Widget-DBIC-0.01.tar.gz
I am waiting for comments.
--
Zbyszek
PS From POD:
# create a widget coupled with a db record
my $widget $schema
, 'Tag', $item );
# process a query
my $result
# and save the values from the query to the database
$result->save_to_db();
METHODS
create_from_config
Method to create widget. The parameters are configuration for
all the widget fields, DBIx::Class schema, the name of the
DBIC Result-set and optionally a DBIC record (item)
- to fill in the current values in the form and as the target
for saving the data, if not
present when saving a new record will be created.
The config is a reference to a list of configuration for
particular
fields. Like:
my $config {
'foreign_class' => 'Dvd',
'widget_element' => [ 'Select', { 'multiple' => 1 }
],
'name' => 'dvds',
'label' => 'Dvds',
'bridge_rel' => 'dvdtags'
},
{
'widget_element' => [
'Textarea',
{
'rows' => 5,
'cols' => 60
}
],
'constraints' => [
{
'max' => '255',
'constraint' => 'Length',
'message' => 'Should be shorten than 255
characters'
},
{
'constraint' => 'All',
'message' => 'The field is required'
}
],
'name' => 'name',
'label' => 'Name'
},
{
'primary_key' => 1,
'name' => 'id',
'label' => 'Id'
}
];
On 9/26/06, Carl Franks <fireartist at gmail.com> wrote:
>
> On 26/09/06, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> > For now I am a bit stuck with the question about the interface. If I
> make
> > it a subclass of HTML::Widget would it be considered bad form if I do
> > something like:
> >
> > ...
> > package HTML::Widget::Result
> >
> > sub save_to_db {
> > ...
>
> I personally wouldn't mind. An alternative though, would be to
> override result() and rebless the object it returns into your own
> Result package.
>
> Carl
>
> _______________________________________________
> Html-widget mailing list
> Html-widget at lists.rawmode.org
> http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
>
--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/html-widget/attachments/20061002/36727c17/attachment.htm
More information about the Html-widget
mailing list