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

Ash Berlin ash at cpan.org
Mon Oct 2 16:45:25 CEST 2006


Are you aware that there is a DBIx::Class::HTMLWidget module?

Perhaps it would be an idea to make changes to that rather than create a 
new module - since currently it does almost nothing.

Ash

Zbigniew Lukasiak wrote:
> 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 = 
> HTML::Widget::DBIC->create_from_config($config, $schema
> , 'Tag', $item );
>
>            # process a query
>            my $result = $widget->process ( $query );
>
>            # 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 
> <mailto:fireartist at gmail.com>> wrote:
>
>     On 26/09/06, Zbigniew Lukasiak <zzbbyy at gmail.com
>     <mailto: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 <mailto:Html-widget at lists.rawmode.org>
>     http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
>
>
>
>
> -- 
> Zbigniew Lukasiak
> http://brudnopis.blogspot.com/
> ------------------------------------------------------------------------
>
> _______________________________________________
> Html-widget mailing list
> Html-widget at lists.rawmode.org
> http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
>   





More information about the Html-widget mailing list