所以,我想将不同的行为绑定到Zend PHP表单上的相同按钮。以下是我现在拥有的代码示例:
if (isset($_POST['submit'])) {
$this->_helper->messenger->addSuccess('Are you sure you would like to delete this link? The link and all statistics tied to it will be permanently deleted if you take this option.');
if (isset($_POST['submit'])) {
...
}
}
但是,无论我点击提交多少次,此代码似乎都会继续显示信使。所以,我的问题是
答案 0 :(得分:0)
根据您要执行的操作更改按钮的值。例如,默认情况下将值设置为1,并在提交一次时,将按钮的值动态设置为2.现在取决于$_POST['submit']
显示警报的值或采取措施。
示例代码:
if (isset($_POST['submit'])) {
if ($_POST['submit'] == 1) {
//submitted first time
$this->_helper->messenger->addSuccess('Are you sure you would like to delete this link? The link and all statistics tied to it will be permanently deleted if you take this option.');
} else if ($_POST['submit'] == 2) {
// second time, so take action
...
}
}