Forum OpenACS Development: help with dubmitting forms

Collapse
Posted by monix m on
Hi All!
I'd appreciate it if somebody could help me with this problem. I have a form with 2 submit buttons, one is called 'agree' and the other one is 'disagree'. I want to redirect the page depending on the button clicked once the form is submitted but I can't seem to make it work. Here is the code I used and I placed it at the top of the form. THe form's name is 'register'.

if {[template::form::get_button register] == "agree"} {
template::form create register -action ${subsite_url}register/user-new
}
else {
template::form create register -action {subsite_url}home/
}

Is there something wroing with my code? Please help as this is my first time writing something using OpenACS. Thank you!

Collapse
Posted by Derick Leony on
template::form create would help if you are creating a new form, use ad_returnredirect to redirect the user to another page.

Regards,

Derick

Collapse
Posted by monix m on
Thanks for the reply..however, I am able to redirect the form just fine except that the [template::form::get_button register] code does not return the value of the button clicked so it always ends up executing the else clause.
Collapse
Posted by Jose Pablo Escobedo Del Cid on
Hi,

I don't know why template::form::get_button doesn't work, but there is an alternative way. You can create the form like this:

<form formname action=page2>
<input type="submit" name="operation" value="agree">
<input type="submit" name="operation" value="disagree">
</form>

and in the page2.tcl, have something like:

if { [string eq $operation agree] } {
something like ad_returnredirect agree_page
} else {
something like ad_returnredirect disagree_page
}

Regards,

jopez