【问题标题】:YiiBooster. TbEditableColumn. Property "attribute" should be definedYiiBooster。 Tb 可编辑列。应定义属性“属性”
【发布时间】:2014-07-01 11:03:39
【问题描述】:

我在 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->属性为空。

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

【问题讨论】:

  • 我解决了这个问题。问题出在 .htaccess 中。我不知道该项目是如何工作的,但它不接受相同的 url,所以我这样做了:'url' => $this->createUrl('stats/update').'/?'.rand( 1,100500),

标签: php yii yii-extensions yii-booster


【解决方案1】:

the source codeTbEditableSaver::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'
    )

【讨论】:

  • 不,它仍然不起作用。即使我删除了条件“if (empty($this->attribute))”,也会有下一个条件“if (empty($this->primaryKey))”。我不知道这有什么问题。
  • 我的代码正在其他项目上运行,但不适用于一个。我不知道原因。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多