yii2 create a button without any model field

1.6k Views Asked by At

I need to have two buttons on my home page, Login and Register. When user click on Login button I need to render a LoginView, while on Register button there will be RegisterView. I see these questions but these also have fields in model(dynamic model):

ActiveForm without model yii2

Yii2 create a form without a model

I don't want to use any model field, I only want to render different view on click event to different buttons. Or in other words, how can I set a button to call specific controller's action on its click event?

How this can be done with Yii2 framework.

1

There are 1 best solutions below

0
On BEST ANSWER

Use

<?= Html::a('label', ['/controller/action'], ['class'=>'btn btn-primary']) ?>