2amigos / yiiwheels

Widget extension library for the YiiStrap extension
http://yiiwheels.2amigos.us
Other
133 stars 77 forks source link

How to pass $data variable into the url parameter in the WhEditableColumn? #80

Closed chaikovskyia closed 10 years ago

chaikovskyia commented 10 years ago

Can't figure out how to make editable columns in the WhGridView.

<?php

$this->widget('yiiwheels.widgets.grid.WhGridView',array(
    'type'=>'striped bordered',
    'dataProvider'=>$dataProvider,
    'fixedHeader'=>true,
    'columns'=>array(
        'id',
        array(
            'name'=>'author',
        ),
        array(
            'name'=>'date',
        ),
       array(
          'name'=>'status',
           'value'=>'Testimonials::getStatus($data->status)',
       ),
        array(
            'name'=>'status',
            'class'=>'yiiwheels.widgets.editable.WhEditableColumn',
            'editable'=>array(
                'url'=>$this->createUrl('admin/testimonials/update', array('id'=>$data->id)),
                'type'=>'select',
                'source'=>Testimonials::getStatuses(),
                'placement'=>'right',
            )
        ),
        array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
            'htmlOptions'=>array('style'=>'width: 50px'),
        ),
    ),
    'htmlOptions'=>array(
        'class'=>'full-grid-view'
    )
));

This line: 'url'=>$this->createUrl('admin/testimonials/update', array('id'=>$data->id)) generates an error : Undefined variable: data

tonydspaniard commented 10 years ago

It is obvious that $data doesn't exists, the only thing you need to pass is the url: 'url'=>$this->createUrl('admin/testimonials/update'), the editable widget will handle the post of the correspondent model's id. Also, remember that you need to set the WhEditableSaver at the controller.

mushahidh commented 9 years ago

@tonydspaniard How to set WhEditableSaver at the controller. No example is provided anywhere.