试试这个:
echo CHtml::button('Delete',
array(
'submit'=>array('controllername/actionname',array('id'=>$id)),
'confirm' => 'Are you sure?'
// or you can use 'params'=>array('id'=>$id)
)
);
正如您所看到的,按钮也会采用特殊的htmlOptions属性clientChange.
更新提交的澄清,从doc link():
submit: string, specifies the URL to submit to. If the current element has a parent form, that form will be submitted, and if ‘submit’ is non-empty its value will replace the form’s URL. If there is no parent form the data listed in ‘params’ will be submitted instead (via POST method), to the URL in ‘submit’ or the currently requested URL if ‘submit’ is empty. Please note that if the ‘csrf’ setting is true, the CSRF token will be included in the params too.
强调我的
正如您所提到的,您想要执行删除操作,默认的gii生成的actionDelete需要url中的id,因此我在url中传递了id,即submit选项.