On 06/02/07, Jonas Alves <[EMAIL PROTECTED]> wrote:

Hi all,
I'm trying to do a Reaction form to do an advanced search.
This is what I have for now:

package MyApp::Model::Action::Search;
use Reaction::Class;
use Reaction::InterfaceModel::Action;

class Search is 'Reaction::InterfaceModel::Action', which {
  has title      => (isa => 'SimpleStr', is => 'rw');
  has state    => (isa => 'Str',  is => 'rw',
                       valid_value_names => sub { [qw/One Two Three/] },
                       valid_values      => sub { [qw/1 2 3/] },
                       name_to_value_map => sub { {qw/One 1 Two 2 Three
3/} },
                       value_to_name_map => sub { {qw/1 One 2 Two 3
Three/} },
                      );
  implements do_apply => sub {};
};

1;

But when it renders the form I get the following error message:
undef error - Can't call method "display_name" without a package or object
reference at
/usr/local/share/perl/5.8.7/Reaction/UI/ViewPort/Field/ChooseOne.pm line 72.

It appears that 'build_value_to_name_map' method is called even when I
pass the value_to_name_map parameter. I'm I doing something wrong? Maybe the
valid_values parameter should not be used this way.

Thanks,
--
Jonas


Hum, I was being silly.

I have to pass the attributes to the ActionForm like this:

$self->push_viewport(
       ActionForm,
       action => $c->model('Action::Search')->new(...),
       Field => {
           state => {
                  valid_value_names => [...],
                  valid_values      => [...],
                  name_to_value_map => {...},
                  value_to_name_map => {...},
           },
       },
   );

--
Jonas
_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to