hello,
In the yii2 we need login form on every page.
We can do this by using login widget.
I have tried create widget same as in yii1 but not working.
If any body have idea please share.
thanks in advance.
hello,
In the yii2 we need login form on every page.
We can do this by using login widget.
I have tried create widget same as in yii1 but not working.
If any body have idea please share.
thanks in advance.
The guide shows it very clear how to enable authentication for a given user: https://www.yiiframework.com/doc/guide/2.0/en/security-authentication
just force user to login page if user do not login yet.
thanks for reply.
In my application on home page user login section in banner.
Inside page user login section in right side.
i have issue how we write login form script.
do you mean file main.php
in layout folder?
yes as well as other page in right column
there are many themes to this,
Thanks for reply can you tell me how we can include in yii2
in your view file you can call <?= $this->render("path/to/the/file", ['data' => 'goes here']); ?>
We have tried this. Form is rendering but not working. While on the login page it’s working file. Any suggestions?
Thanks
We have tried this. Form is rendering but not working. While on the login page it’s working file. Any suggestions?
Thanks
strange why u need login page in every page? why not just create a link login? and redirect user to login page? so u can easy make role of acces page, if u insist just use modal
it’s client requirement.
make sure the form is pointing to the right controller/action.
new ActiveForm([
// ...
'action' => 'action/url/goes/here', // you can also make use of the Url::to helper
// ...
]);
actually there is already example in yii2 view/layouts/main.php, if u look at logout button its actually a form and always in every page. u can just modify it.
here something like this
Html::beginForm(['/site/login'], 'post') Html::submitButton( 'Login', ['class' => 'btn btn-link logout'] ) Html::endForm()
u jut need to add input username and password and change to site/login