Also, if you have different actions depending on the button that submits
the request, you could
use Javascript to alter the "action" of the form prior to submit.
The form tag looks like:
<form id="testform" action="" method="post">
The inputs look something like:
<input type="submit" onClick="setAction('local');" name="buy"
value="Local" />
<input type="submit" onClick="setAction('remote');" name="buy"
value="LIVE!" />
And the setAction function something like:
<script>
function setAction(loc) {
if (loc == 'local') {
document.getElementById('testform').action = '/controller/action';
} else {
document.getElementById('testform').action =
'http://www.remoteurl.nl/someform.php';
}
}
</script>
Ofcorse this could probably look a little smoother using your favorite
Javascript library...
Hope this helps,
Ramon de la Fuente
lightflowmark wrote:
This is true of all HTML forms (AFAIK). I would approach this by having both
forms submit to the same action (as you must), and using the redirector to
conditionally redirect to the desired ultimate action, something like:
MyController.php:
public function myFormAction()
{
if($this->getRequest()->getParam('button1'))
{
$this->_helper->getHelper('Redirector')->gotoUrl('http://othersite.com/',$this->getRequest()->getParams())
}
else
{
//do form stuff locally
}
}
Cheers,
Mark
sagittariidae wrote:
Hey all,
I might be going the wrong way about it but I am looking to include 2
submit buttons on a form to choose from, one button posting to a script on
another site and one posting back to an action in the same controller
(with the ability to use the posted variables once there). Is this
possible using Zend Form? Surely the form action has to be assigned before
the form is actually created so that is why I am stumped. I suppose I
could have the form post back to a single action that checks which button
has been pressed but then how would I post the variables to the subsequent
script, would I use Zend_Http_Client?
Many thanks, Matt