warrence / yii2-kartikgii

Gii CRUD Generator base on kartik-v extension
BSD 3-Clause "New" or "Revised" License
33 stars 39 forks source link

bad url generated for update button (grid). #1

Open jarekkozak opened 9 years ago

jarekkozak commented 9 years ago

When you generate controller for CRUD operations in default controller folder (namespace) i.e. frontapp/controllers everything is ok. But if you generate in sub-namespace i.e. "frontend/controllers/db" wrong url is created for update operation.

[
                'class' => 'yii\grid\ActionColumn',
                'buttons' => [
                    'update' => function ($url, $model) {
                        return Html::a('<span class="glyphicon glyphicon-pencil"></span>',
                                Yii::$app->urlManager->createUrl(['organization/view',
                                    'id' => $model->id, 'edit' => 't']),
                                [
                                'title' => Yii::t('yii', 'Edit'),
                        ]);
                    }
                    ],
                ],
            ],

if you change line

- Yii::$app->urlManager->createUrl(['organization/view',
+ Yii::$app->urlManager->createUrl([Yii::$app->controller->id.'/view',

works ok.

regards, Jarek

tilhom commented 9 years ago

If you're still using the module you need to add the following: