Added support for data-method and data-confirm.

This commit is contained in:
Qiang Xue 2013-09-18 23:11:55 -04:00
parent f7a28f3df0
commit 8a599e9474
2 changed files with 12 additions and 2 deletions

View File

@ -3,7 +3,9 @@
namespace app\controllers;
use Yii;
use yii\web\AccessControl;
use yii\web\Controller;
use yii\web\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;
@ -13,7 +15,7 @@ class SiteController extends Controller
{
return array(
'access' => array(
'class' => \yii\web\AccessControl::className(),
'class' => AccessControl::className(),
'only' => array('login', 'logout'),
'rules' => array(
array(
@ -28,6 +30,12 @@ class SiteController extends Controller
),
),
),
'verbs' => array(
'class' => VerbFilter::className(),
'actions' => array(
'logout' => array('post'),
),
),
);
}

View File

@ -36,7 +36,9 @@ app\config\AppAsset::register($this);
array('label' => 'Contact', 'url' => array('/site/contact')),
Yii::$app->user->isGuest ?
array('label' => 'Login', 'url' => array('/site/login')) :
array('label' => 'Logout (' . Html::encode(Yii::$app->user->identity->username) .')' , 'url' => array('/site/logout')),
array('label' => 'Logout (' . Yii::$app->user->identity->username .')' ,
'url' => array('/site/logout'),
'linkOptions' => array('data-method' => 'post')),
),
));
NavBar::end();