Bloodhound
Bloodhound

Reputation: 2966

Open in a new window in yii2 [For a button dropdown]

how can one open a link in a new tab. in my case i wanna do it in the following code

if( Yii::$app->session->get('department_id') == 5 )
                                    {
                                        $items[]    =   ['label' => 'Offer Letter',
                                        'url' => Yii::$app->urlManager->createUrl(['dashboard/print_offer_letter', 'id' => $data->id]),

                                        ];

i tried like this but didn't work

$items[]    =   ['label' => 'Offer Letter', ['title'=>'go','target'=>'_blank'],
                                        'url' => Yii::$app->urlManager->createUrl(['dashboard/print_offer_letter', 'id' => $data->id]),

                                        ];

any help would be appreciated.

Upvotes: 0

Views: 1188

Answers (1)

Chinmay Waghmare
Chinmay Waghmare

Reputation: 5456

I think you can use something like below:

$items[] = [
            'label' => 'items',
            'url' => Yii::$app->urlManager->createUrl(['dashboard/print_offer_letter', 'id' => $data->id]),
            'linkOptions' => ['target'=>'_blank']
        ];

Upvotes: 2

Related Questions