GridView link to external url

Hello,

I am displaying a gridview and one column contains an ID. I want the user to be able to click on the ID and be taken to an external website but I cannot seem to create an external link.

Here is my code:


        [

            'label' => 'ID',

            'format' => 'raw',

            'attribute' => 'name',

            'value' => function ($data) {

                return Html::a($data['name'], [$data['href']]);

            },

        ],



The array looks something like this:


 

     'name' => 'test',

     'id'=> '17',

     'href' => 'https://test.com/?id=17'



The output is always a reference to my own site ie:

www.mysite.com/basic/web/?.

Many thanks for your help

I have just found the solution:

remove the array brackets:


return Html::a($data['name'], $data['href']);

Just make sure that the href includes the http or https component.