Create button with link in Yii2
Asked 07 September, 2021
Viewed 3.1K times
  • 53
Votes

I am trying to setup a button with a link to a view. However yiiootstrapButton does not have a property url. I would rather use Yii as supposed to just use flat out php. The code as below would be the ideal situation, but since the url option does not exist, is there an other way to fix this using Yii?

echo Button::Widget([
    'label' => 'label',
    'options' => ['class' => 'btn btn-primary'],
    'url' => Url::toRoute(['/controller/action']),
]);

5 Answer