質問

I am trying to replace yii default select widget with yiiwheels select widget.

Code using yii select widget

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

Tring to get something like this

<?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')));?>

I get an error on form submission that branch_id field can't be blank.

How do i associate it with the current form model?

Here is a link to Yiiwheels API docs

役に立ちましたか?

解決

Instead of 'name' field, i had to use 'attribute' field.

<?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')));?>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top