Hello I have a form with two submit buttons. I do not want to have js to detect what submit button was used to redirect the script for two different actions. Looking to the documentation I found out conditional matching. So, my doubt is: is there any chance on using conditional matching to detect what submit button was used? (basically, is there any way to access to the CGI parameters on the conditional matching portion of routes?) Thank you kindest regards, ambs
On 13/01/2011 21:43, ambs wrote:
Hello
I have a form with two submit buttons. I do not want to have js to detect what submit button was used to redirect the script for two different actions.
Looking to the documentation I found out conditional matching.
So, my doubt is: is there any chance on using conditional matching to detect what submit button was used? (basically, is there any way to access to the CGI parameters on the conditional matching portion of routes?)
didn't read carefully the documentation: "(on the useragent and the hostname at the moment):" damn. probably I can hack that for 1.3...
On 13/01/2011 21:43, ambs wrote:
Hello
I have a form with two submit buttons. I do not want to have js to detect what submit button was used to redirect the script for two different actions.
Looking to the documentation I found out conditional matching.
So, my doubt is: is there any chance on using conditional matching to detect what submit button was used? (basically, is there any way to access to the CGI parameters on the conditional matching portion of routes?)
didn't read carefully the documentation: "(on the useragent and the hostname at the moment):" damn. probably I can hack that for 1.3...
On Thu, Jan 13, 2011 at 10:52 PM, ambs <ambs+dancer@perl-hackers.net<ambs%2Bdancer@perl-hackers.net>
wrote:
On 13/01/2011 21:43, ambs wrote:
Hello
I have a form with two submit buttons. I do not want to have js to detect what submit button was used to redirect the script for two different actions.
Looking to the documentation I found out conditional matching.
So, my doubt is: is there any chance on using conditional matching to detect what submit button was used? (basically, is there any way to access to the CGI parameters on the conditional matching portion of routes?)
didn't read carefully the documentation:
"(on the useragent and the hostname at the moment):"
damn. probably I can hack that for 1.3...
should not be too hard to add this. If you need help ping me on #dancer (I've also some other ideas in my mind for conditional match)
On Thu, 2011-01-13 at 21:43 +0000, ambs wrote:
Hello
I have a form with two submit buttons. I do not want to have js to detect what submit button was used to redirect the script for two different actions.
Looking to the documentation I found out conditional matching.
So, my doubt is: is there any chance on using conditional matching to detect what submit button was used? (basically, is there any way to access to the CGI parameters on the conditional matching portion of routes?)
I'd be inclined to give them different names, e.g.: <form ... action="/dosomething"> ... <input type="submit" name="foo" value="Do Foo" /> <input type="submit" name="bar" value="Do Bar" /> </form> and have them submit to a route which calls a different sub depending on the button clicked, e.g: post '/dosomething' => sub { if (params->{foo}) { do_foo(); } else { do_bar(); } }; Alternatively, it seems a touch hackish, but you could have multiple routes which pass if the right button wasn't clicked, e.g.: post '/dosomething' => sub { pass unless params->{foo}; # Do some foo here }; post '/dosomething' => sub { pass unless params->{bar}; # Do some bar here }; Cheers Dave P -- David Precious <davidp@preshweb.co.uk> ("bigpresh") http://www.preshweb.co.uk/
participants (5)
-
Alberto Simoes -
ambs -
David Precious -
franck -
sawyer x