【发布时间】:2013-08-08 15:42:18
【问题描述】:
我在 Yii 中使用 get 方法与 Cactiveform 作斗争。这是我的代码:
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'inlineForm',
'type'=>'inline',
'method'=>'get',
'action'=> array('searchview'),
'htmlOptions'=>array('class'=>'well'),
));
echo $form->dropDownListRow($model, 'year',$arrYears);
echo $form->dropDownListRow($model, 'month',$mons);
echo $form->dropDownListRow($model, 'day',$days);
$this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'type'=>'primary','label'=>'Vyhledat'));
$this->endWidget(); ?>
当我点击提交按钮时,我得到了这个 URL:
http://stavbadomusvepomoci.cz/stavba_naklady/index.php?r=expenses%2Fsearchview&Expenses%5Byear%5D=2013&Expenses%5Bmonth%5D=0&Expenses%5Bday%5D=0&yt0=
问题是字段的名称是 Expenses[year] 插入的只是:year。当我删除它时,这个网址就可以正常工作了。
http://stavbadomusvepomoci.cz/stavba_naklady/index.php?r=expenses%2Fsearchview&year=2013&month=0&day=0&yt0=
我的搜索返回 400 错误,因为它无法识别该 url。我使用调节器 CHtml::beginForm 进行这项工作,但我希望这可以使用 CActive 表单。
所以我的问题是:我怎样才能摆脱 url 中的 Expenses[] 以便 cactiveform 起作用。
感谢您的回答!
【问题讨论】:
标签: yii