[ic] Dancer2 form back button

dev2 at adeux.net dev2 at adeux.net
Wed Apr 13 17:35:34 UTC 2016


Hi,

About two hours after I asked the question in the previous email, I was able to work out the answer.  So just incase someone stumbles on the previous email searching for a similar solution - this is what I did:

Create the buttons in the HTML form and give them all the same name, but set the value field to a suitable string:

<button type="submit" name="ActionButton" value="Edit" >Back</button>

<button type="submit" name="ActionButton" value="Confirm" >Forward</button>

Then in the dancer app.pm file:

post '/currentpage' => sub {
my $ActionValue = body_parameters->get('ActionButton');
   if ($ActionValue eq "Edit") {
       # any processing then redirect to target page
       redirect ('/previouspage');
   };
   if ($ActionValue eq "Confirm") {
       # commands
       redirect ('/nextpage');
   }
}

I hope that helps someone.

M



More information about the interchange-users mailing list