Hi there,

I've extracted the options building from _Group to Model::DBIC.  It
should be entirely compatible change so I committed it.

Now I have another change, which can be incompatible in very
degenerate circumstances. When someone sets the 'db' option on a
Select box with some attributes but with no 'model' (ie actually
resultset) it will fill the Select box with empty option list.  It
still passess all the tests - but Carl asked me to be careful with
commits - so I am sending the patch with this email for you to check
it.

Eventually I think the goal should be that the options for a Select
(or other _Group) element should be sourced whenever $self->db is set
- unfortunately currently it is always set (to an empty hash if there
is no db options).  I would also rename 'db' to 'from_model' - so that
the name would be appropriate when we have other then database models.

I am waiting for green light to commit the attached patch.

Cheers,
Zbigniew
http://perlalchemy.blogspot.com/
Index: lib/HTML/FormFu/Element/_Group.pm
===================================================================
--- lib/HTML/FormFu/Element/_Group.pm	(revision 754)
+++ lib/HTML/FormFu/Element/_Group.pm	(working copy)
@@ -23,12 +23,10 @@
 sub process {
     my ($self) = @_;
 
-    my $context = $self->form->stash->{context};
-    my $args    = $self->db;
+    my $args = $self->db;
 
-    if ( $args && $args->{model} && defined $context ) {
-
-       $self->options( [ $self->form->model->options_from_model( $self, $args ) ] );
+    if ( $args and keys %$args ) {
+        $self->options( [ $self->form->model->options_from_model( $self, $args ) ] );
     }
 }
 
Index: lib/HTML/FormFu/Model/DBIC.pm
===================================================================
--- lib/HTML/FormFu/Model/DBIC.pm	(revision 754)
+++ lib/HTML/FormFu/Model/DBIC.pm	(working copy)
@@ -12,8 +12,9 @@
 
     my $form = $base->form;
     my $context = $form->stash->{context};
-
-    my $model = $context->model( $attrs->{model} );
+    my $schema  = $form->stash->{schema};
+    return if !defined $context and !defined $schema;
+    my $model = $schema || $context->model( $attrs->{model} );
     return if !defined $model;
 
     $model = $model->resultset( $attrs->{resultset} )
_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to