yii YiWheels选择框与模型的关联

uoifb46i  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(150)

我正在尝试用yiiwheels选择小工具替换yii默认的选择小工具。
使用yii select小工具的代码

<?php echo $form->dropDownList($model,'branch_id', CHtml::listData(Branches::model()->findAll(array('order' => 'branch_name')),'id','branch_name'));?>

特灵得到这样的东西

<?php $this->widget('yiiwheels.widgets.formhelpers.WhSelectBox',array('name' => 'branch_id', 'size' => 'input-large', 'model' => $model, 'data' => CHtml::listData(Branch::model()->findAll(array('order' => 'branch_name')),'id','branch_name')));?>

提交表单时出现分支_id字段不能为空的错误。
如何将其与当前表单模型关联?
这里是Yiiwheels API docs的链接

brc7rcf0

brc7rcf01#

而不是'名称'字段,我不得不使用'属性'字段。

<?php $this->widget('yiiwheels.widgets.formhelpers.WhSelectBox',array('attribute' => 'branch_name', 'size' => 'input-large', 'model' => $model, 'data' => CHtml::listData(Branch::model()->findAll(array('order' => 'branch_name')),'id','branch_name')));?>

相关问题