[jifty-devel] Action params at run time
Salih Gönüllü
salih at ip-plus.net
Fri May 11 16:38:56 EDT 2007
Jesse Vincent wrote:
>
> On May 11, 2007, at 3:53 AM, Salih Gönüllü wrote:
>
>>
>> Hi all,
>>
>> Is it possible to 'declare' Action params at runtime just before using
>> them ? something like:
>>
>> In MyApp::Action::MyAction
>>
>> my %new_params = declare {
>> param 'foo' => ... ;
>> param 'bar'=> ... ;
>> };
>> $self->merge_with_params(\%new_params); # or another method
>
> I'm not sure it's possible. (I'm not sure it's not.) Can you describe
> what you're really trying to do?
>
> Jesse
>
Some of my params update some external datasource which has sort of a
dynamic schema (different params for different roles, ACLs, params could
change etc..)
for this now I am doing the following in the template:
<%args>
$runtime_params
<%/args>
<%init>
my $action = Jifty::web->new_action(class => 'MyAction');
</%init>
% my @fields = sort {..}keys %$runtime_params
% foreach my $field ( @fields ) {
$value = ...;
<% $action->form_field( $field, default_value => $value,
render_as => $runtime_params->{$field}{render_as})
....
% }
In the case of a 'Select' field, I couldn't give the available values to
the form_field method ( I had to override available_values in MyAction ).
With form_field(), I cannot profit from the ajax
validation/canonicalization neither.
Thanks in advance,
-salih
More information about the jifty-devel
mailing list