[cgiapp] submit returns allways to the same run mode.

Rhesa Rozendaal perl at rhesa.com
Sun Mar 14 04:55:36 EDT 2010


> On Sun, Mar 14, 2010 at 10:42 AM, Erez David <introx at gmail.com> wrote:
> 
>> Hi,
>>
>> In my application I have few run modes (Each run mode represent a different
>> tab in the application) but whenever I press the submit button of one of the
>> tabs, It qllways bring me back to the first run mode which I have defined in
>> the setup by calling the start_mode method.
>>
>> sub setup {
>> my $self = shift;
>>         $self->start_mode('builder_project');
>>         $self->mode_param('rm');
>>     $self->run_modes(
>>
>>
>>         'builder_project' => 'builder_project_tab',
>>         'builder_users' => 'builder_users_tab',
>>  'builder_dir_structure' => 'builder_dir_structure_tab',
>>
>> In the html of this tab I have the following form tag: <form name=conf
>> method="post" action="?rm=configuration">

CGI::Application only looks for $self->query->param('rm') by default, so for 
POST requests, you need to add a hidden input with the rm. The URL param you 
put in the action is ignored.

This means your form should look like:

   <form name="conf" method="post" action="?">
     <input type="hidden" name="rm" value="configuration">

The other alternative is to make cgiapp look for a url param if there is no 
regular query param, but that's a bit more involved.

HTH,
Rhesa


More information about the cgiapp mailing list