I've uploaded a first version to <a href="http://zby.aster.net.pl/HTML-Widget-DBIC-0.01.tar.gz">http://zby.aster.net.pl/HTML-Widget-DBIC-0.01.tar.gz</a><br><br>I am waiting for comments.<br><br>--<br>Zbyszek<br><br>PS From POD:
<br><br> # create a widget coupled with a db record<br> my $widget = HTML::Widget::DBIC->create_from_config($config, $schema<br>, 'Tag', $item );<br><br> # process a query<br> my $result = $widget->process ( $query );
<br><br> # and save the values from the query to the database<br> $result->save_to_db();<br><br>METHODS<br> create_from_config<br> Method to create widget. The parameters are configuration for
<br> all the widget fields, DBIx::Class schema, the name of the <br> DBIC Result-set and optionally a DBIC record (item) <br> - to fill in the current values in the form and as the target <br>
for saving the data, if not<br> present when saving a new record will be created.<br><br> The config is a reference to a list of configuration for particular<br> fields. Like:<br> my $config = [
<br> {<br> 'foreign_class' => 'Dvd',<br> 'widget_element' => [ 'Select', { 'multiple' => 1 } ],<br> 'name' => 'dvds',
<br> 'label' => 'Dvds',<br> 'bridge_rel' => 'dvdtags'<br> },<br> {<br> 'widget_element' => [<br> 'Textarea',
<br> {<br> 'rows' => 5,<br> 'cols' => 60<br> }<br> ],<br> 'constraints' => [
<br> {<br> 'max' => '255',<br> 'constraint' => 'Length',<br> 'message' => 'Should be shorten than 255
<br> characters'<br> },<br> {<br> 'constraint' => 'All',<br> 'message' => 'The field is required'
<br> }<br> ],<br> 'name' => 'name',<br> 'label' => 'Name'<br> },<br> {<br> 'primary_key' => 1,
<br> 'name' => 'id',<br> 'label' => 'Id'<br> }<br> ];<br><br><br><br><div><span class="gmail_quote">On 9/26/06, <b class="gmail_sendername">
Carl Franks</b> <<a href="mailto:fireartist@gmail.com">fireartist@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 26/09/06, Zbigniew Lukasiak <<a href="mailto:zzbbyy@gmail.com">zzbbyy@gmail.com</a>> wrote:<br>> For now I am a bit stuck with the question about the interface. If I make<br>> it a subclass of HTML::Widget would it be considered bad form if I do
<br>> something like:<br>><br>> ...<br>> package HTML::Widget::Result<br>><br>> sub save_to_db {<br>> ...<br><br>I personally wouldn't mind. An alternative though, would be to<br>override result() and rebless the object it returns into your own
<br>Result package.<br><br>Carl<br><br>_______________________________________________<br>Html-widget mailing list<br><a href="mailto:Html-widget@lists.rawmode.org">Html-widget@lists.rawmode.org</a><br><a href="http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget">
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget</a><br></blockquote></div><br><br clear="all"><br>-- <br>Zbigniew Lukasiak<br><a href="http://brudnopis.blogspot.com/">http://brudnopis.blogspot.com/</a>