문제

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