Mailing List Archive

Dancer2 form back button
Hi,

Not really an interchange question, but I know that IC6 is written in dancer and I know there is a lot of expertise here. I am just experimenting with dancer 2 and wanted to create a route with an entry form followed by a confirmation page. On the confirmation page form I would like to have back and confirm buttons to allow the user to go back and edit the entries if there are any mistakes.

Is there an easy way to do that?

Thanks

M

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Dancer2 form back button [ In reply to ]
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

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users