2012-07-30 64 views
0

我使用CHtml :: button与其他动作(无形式)上的“提交”,它显示页面,但是当我点击BACK,然后点击NEXT时,它显示文档已过期“document expired”with button submit on other action

  <?php echo CHtml::button('title', array('submit' => array('/'.$_GET['id'].'/smthing/profile'))); //)?> 
+1

'文件Expired'表明您已经取得了'POST'请求​​,然后尝试浏览到同一文件再次使用浏览器的导航按钮(后退,前进)。您应该使用[POST/Redirect/GET](http://en.wikipedia.org/wiki/Post/Redirect/Get)模式来避免这种情况。 – DaveRandom 2012-07-30 09:42:17

+0

@DaveRandom我想使用按钮像链接http://www.yiiframework.com/wiki/48/by-example-chtml/#hh1 – gormit 2012-07-30 09:55:35

+0

你有'

'元素包装这个按钮或不?看看这个[JS源代码](http://code.google.com/p/yii/source/browse/trunk/framework/web/js/source/jquery.yii.js?r=1707)如果按钮不包含在表单元素中,Yii使用'POST'方法创建一个,这不能被覆盖,这是坦率的荒谬。试试'echo'';回声CHtml ::按钮(...); echo'
';' – DaveRandom 2012-07-30 10:02:38

回答

0

尝试从POST更改为GET,例如为活性形式:

$form = $this->beginWidget('CActiveForm', array(
    'action' => '/', 
    'method' => 'get', 
    'enableClientValidation' => true, 
    'clientOptions' => array(
     'validateOnSubmit' => true, 
    ), 
)); 
echo Chtml::submitButton('Submit'); 
$this->endWidget();