problem 1
Kindly assist in placing a Modal Link on the Nav widget which works when launched from a Html link.
Tried this to no avail
//views/layout/main.php
$menuItems[] = ['label' => Yii::t('app', 'Modal Login Button'), 'url' => ['/site/login/']];
Below Html link works in main.php and branches route only. Branches applies the modal form too.
<?= Html::button('Login', ['value'=>Url::toRoute('/site/login/'), 'class' => 'btn btn-success', 'id'=>'modaLoginButton']) ;?>
Problem 2.
A login modal form only launches in main.php and branches route. Branches also applies the modal form.
It should be launched from any route. Code is as follows
Link in main.php
<?= Html::button('Login', ['value'=>Url::toRoute('/site/login/'), 'class' => 'btn btn-success', 'id'=>'modaLoginButton']) ;?>
//AppAsset.php
public $js = [
'js/main.js',
];
//main.js in themes/light/js
$(function () {
$('#modalButton').click(function(){
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});
});
//login stuff
$(function () {
$('#modaLoginButton').click(function(){
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});
});
//views/site/index.php
<?php
use yii\bootstrap\Modal;
Modal::begin([
'header'=>'<h4>Login</h4>',
'id'=>'modal',
'size'=>'modal-lg',
]);
echo "<div id='modalContent'></div>";
Modal::end();
?>
Partial Solution - Login using Modal popup from any route using a Html link
Ive discovered i have to the below code in any view from where i need to popup the login form.
Question - Is there a way to include the following globally to all views
<?php
use app\assets\AppAsset;
use yii\bootstrap\Modal;
Modal::begin([
'header'=>'<h4>Login</h4>',
'id'=>'modal',
'size'=>'modal-lg',
]);
echo "<div id='modalContent'></div>";
Modal::end();
?>
Lastly forks , still need the nav widget equivalent of the Html link below
<?php $menuItems[] = ['label' => Yii::t('app', 'Modal Login Button'), 'url' => ['/site/showmodal/']]; ?>