[jifty-devel] Jifty::Action & Scalar::Defer

Selena Deckelmann selena at chrisking.com
Tue Aug 15 18:52:56 EDT 2006


Apologies if this is in the docs --

I'm trying to use some select menus and here's what I came up with for 
an action:

package BCC::Action::CreateTrip;

use Jifty::Param::Schema;
use Jifty::Action schema {

param 'trip_challenge' =>
         label is 'Challenge',
         render as 'Select',
         available are defer {
                 my $challenges = BCC::Model::ChallengeCollection->new;
                 $challenges->unlimit;
                 [{
                         collection => $challenges,
                         display_from => 'challenge_code',
                         value_from => 'id',
                 }];
         };
};

This doesn't work out of the box.  I dug around in Jifty::Action, in 
_values_for_field() on line 822 found:

>     return $vv_orig unless ref $vv_orig eq 'ARRAY';

My param 'available' is a Scalar::Defer so 'ref $vv_orig' returns zero. 
  Commenting that out fixes the problem.  Is there a simple way to fix 
this (other than commenting out the test)?  Or am I just writing my 
action incorrectly?

Also, in creating this action, I broke my ability to insert rows in 
this table.  Is there an additional method I should be declaring here 
to make this happen?

-selena



More information about the jifty-devel mailing list