Yii1-模板中的GridView使用项目ID

时间:2019-03-12 15:38:47

标签: php yii yii1.x

如何在模板中(在GridView中)传递项目ID?

当我使用'data-item-id'=>'$ data-> id'时,将 $ data-> id 用作数据值'data-item-id'=> $ data-> id 我遇到错误未定义$ data

我该怎么做?

我有此代码:

'template' => '{update} {enable} {disable}',
            'buttons' => array(
                'update' => array(
                    'label' => 'Edit',
                    'icon' => 'fa fa-lg fa-edit',
                    'url'   => 'Yii::app()->controller->createUrl("update", array("id" => $data->id))',
                    'options' => array(
                        'class' => 'manage-email-list-button',
                    ),
                ),
                'enable' => array(
                    'label' => 'Enable',
                    'icon' => 'fa fa-lg fa-check',
                    'url'   => 'Yii::app()->controller->createUrl("enable")',
                    'visible' => '(int) $data->is_enabled === 0',
                    'options' => array(
                        'class' => 'enable-system-email',
                        'data-related-grid' => $gridId,
                        'data-item-id' =>  '$data->id'
                    ),
                ),
                'disable' => array(
                    'label' => 'Disable',
                    'icon' => 'fa fa-lg fa-times',
                    'url'   => 'Yii::app()->controller->createUrl("disable", array("id" => $data->id))',
                    'visible' => '(int) $data->is_enabled === 1',
                    'options' => array(
                        'class' => 'disable-system-email',
                        'data-related-grid' => $gridId,
                        'data-item-id' => '$data->id'
                    ),
                ),
            ),

0 个答案:

没有答案