1

I have a problem with TbEditedableColumn in YiiBooster 4.0.1

View:

$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'
            )
        )
    ),
)

);

Controller:

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

When I try to save the edited fields, I got this exception: Property "attribute" should be defined.

$es->attributes is empty.

How to fix that? Thanks.

Holger Just
  • 52,918
  • 14
  • 115
  • 123
Alex Pavlov
  • 571
  • 1
  • 7
  • 24
  • I solved this. The problem was in .htaccess. I don't know how works that project, but it don't accept the same url, so I did this: 'url' => $this->createUrl('stats/update').'/?'.rand(1,100500), – Alex Pavlov Jul 02 '14 at 09:12

1 Answers1

0

From the source code, TbEditableSaver::update() obtains the attribute from a post or get parameter 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.'));
}

In order for this parameter to be sent in the update request it needs to be defined in the editable array. To fix this:

'class' => 'application.extensions.booster.widgets.TbEditableColumn',
    'name' => 'login',
    'sortable' => false,
    'editable' => array(
        'name' => 'login',
        'url' => $this->createUrl('stats/editableSaver'),
        'placement' => 'right',
        'inputclass' => 'span3'
    )
topher
  • 14,790
  • 7
  • 54
  • 70
  • No, it still doesn't work. Even though I delete conditions "if (empty($this->attribute))" there will be the next condition "if (empty($this->primaryKey))". I don't know what's wrong with that. – Alex Pavlov Jul 01 '14 at 17:22
  • My code is working on other project, but doesn't work on one. I don't know the reason. – Alex Pavlov Jul 02 '14 at 00:22