On 07/02/07, Matt S Trout <[EMAIL PROTECTED]> wrote:


On 6 Feb 2007, at 18:21, Jonas Alves 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 {};
> };
>

I'd just pass valid_values => sub { [ qw/One Two Three/ ] } and treat
it as an enum until you get to do_apply - do_apply should return
appropriate data, perhaps doing the search itself and returning the
resultset. Then you can pass an on_apply_callback to the ActionForm
that populates the ListView off the returned rs.


I will try that. Thanks :)
What is the best way to validate the form only when it is submited? I don't
want the messages to be displayed the first time the form is rendered.

Thanks,
--
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