"_blank", but in " /> "_blank", but in " /> "_blank", but in "/>

How to open PDF in new tab using KNP Menu Bundle

130 views Asked by At

I want to open PDF document in new TAB while pressing button "Download PDF".

Found a solution on SO that you have to add 'target' => "_blank", but in my case it's not working and I don't have an idea why. Tried setLinkAttribute, setChildAttribute, setAttribute and none of these are working. Also, content disposition inline already added.

$menu
     ->addChild(
     'download_file',
     [
       'route' => 'admin_download_file',
       'routeParameters' => [
             'token' => $admin->getToken(),
        ],
     ]
            )
     ->setAttribute('type', 'link')
     ->setLinkAttribute('target', '_blank');
1

There are 1 answers

0
Alex On
->setLinkAttributes(['target', '_blank']);

or I think on child level something like:

->addChild(
 'download_file',
 [
   'route' => 'admin_download_file',
   'routeParameters' => [
         'token' => $admin->getToken(),
    ],
   'linkAttributes' => ['target' => '_blank']
 ]
        )