How to define id in ActionColumn

Hi guys,

Following links in ActionColumn(of kartik) works for creating(the last one),but not for updating(one before the last one).

I will get error:


Bad Request(#404)Missing parameter id

actionUpdate in controller needs an id as parameter(probably primary key) but it won’t be given. So, my question is: How should I define id in link?





$gridColumn_telefon = [

    [

        'class' => 'yii\grid\ActionColumn',

        'template' => '{neu_anlegen}<br>{ansicht}<br>{updaten}<br>{erzeugen}<br>{delete}',

        'buttons' => [

            'neu_anlegen' => function ($url) {

                return Html::a('<span class="glyphicon glyphicon-save-file"></span>', $url = 'saveAsNew_telefon', ['title' => 'Duplizieren']);

            },

            'ansicht' => function ($url) {

                return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url = 'view_telefon', ['title' => 'Anzeigen']);

            },

            'updaten' => function ($url, $id) {

                return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url = 'telefon_update', ['title' => 'Bearbeiten']);

            },[b]//this won't work,'cause id will be needed,but it's nowhere defined[/b]

            'erzeugen' => function ($url) {

                return Html::a('<span class="glyphicon glyphicon-road"></span>', $url = 'telefon_create', ['title' => 'Erzeugen']);

            }, [b]//this will work,'cause id won't be needed[/b]

        ],

    ],



Of course, I could determine id in controller,without giving it as parameter, but following code works without defining

id seperatly in link:





    [

        'class' => 'yii\grid\ActionColumn',

        'template' => '{save-as-new} {view} {update} {delete}',

        'buttons' => [

            'save-as-new' => function ($url) {

                return Html::a('<span class="glyphicon glyphicon-copy"></span>', $url, ['title' => 'Save As New']);

            },

        ],

    ],



P.S.: I have two independent tables in one GridView

I got it. It’s according giving informations of link uppon:





$gridColumn_telefon = [

    [

        'class' => 'yii\grid\ActionColumn',

        'template' => '{view_telefon}<br>{update_telefon}<br>{neu_anlegen}<br>{delete}',

        'buttons' => [

            'view_telefon' => function ($url, $id) {

                return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['title' => 'Anzeigen']);

            },

            'update_telefon' => function ($url, $id) {

                return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => 'Bearbeiten']);

            },

            'neu_anlegen' => function ($url, $id) {

                return Html::a('<span class="glyphicon glyphicon-save-file"></span>', $url, ['title' => 'Duplizieren']);

            },

        ],

    ],