YiiBooster。 TbEditableColumn。应定义属性“属性”

时间:2014-07-01 11:03:40

标签: php yii yii-extensions yii-booster

我在YiiBooster 4.0.1中遇到TbEditedableColumn问题

查看:

$this->widget(
'application.extensions.booster.widgets.TbGridView',
array(
    'type' => 'striped bordered',
    'dataProvider' => new CActiveDataProvider('Stats'),
    'columns' => array(
        'pid',
        array(
            'class' => 'application.extensions.booster.widgets.TbEditableColumn',
            'name' => 'login',
            'sortable' => false,
            'editable' => array(
                //'model'  => $model,
                //'attribute' => 'login',
                'url' => $this->createUrl('stats/editableSaver'),
                'placement' => 'right',
                'inputclass' => 'span3'
            )
        )
    ),
)

);

控制器:

public function actionEditableSaver()
        {
            Yii::import('application.extensions.booster.components.TbEditableSaver');
            $es = new TbEditableSaver('Stats');
            $es->update();
        }

当我尝试保存已编辑的字段时,我遇到了这个异常:应该定义属性“属性”。

$ es->属性为空。

如何解决这个问题?感谢。

1 个答案:

答案 0 :(得分:0)

the source code开始,TbEditableSaver::update()从帖子或获取参数name获取属性:

$this->attribute = yii::app()->request->getParam('name');
$this->value = yii::app()->request->getParam('value');

//checking params
if (empty($this->attribute)) {
    throw new CException(Yii::t('TbEditableSaver.editable', 'Property "attribute" should be defined.'));
}

为了在更新请求中发送此参数,需要在editable数组中定义。解决这个问题:

'class' => 'application.extensions.booster.widgets.TbEditableColumn',
    'name' => 'login',
    'sortable' => false,
    'editable' => array(
        'name' => 'login',
        'url' => $this->createUrl('stats/editableSaver'),
        'placement' => 'right',
        'inputclass' => 'span3'
    )