Page 1 of 1

Login Box

PostPosted: 09 Dec 2013, 11:26
by amdawi0
Hello,
I want to display login form in footer for every page if user is not logged.



Thanks,

Re: Login Box

PostPosted: 09 Dec 2013, 13:55
by Foton
In file protected\views\layouts\main.php after
Code: Select all
<div class="footer"> 

insert code
Code: Select all

<?php if (Yii::app()->user->isGuest): ?>
<div class="form">
    <?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'login-form',
        'enableClientValidation'=>false,
        'action'=>Yii::app()->controller->createAbsoluteUrl('/site/login')
        /*'clientOptions'=>array(
            'validateOnSubmit'=>true,
        ),*/
    ));
    $loginForm = new LoginForm;
    ?>

    <p class="note"><?php echo Yii::t('common', 'Fields with <span class="required">*</span> are required.'); ?></p>

    <div class="row">
        <?php echo $form->labelEx($loginForm,'username'); ?>
        <?php echo $form->textField($loginForm,'username'); ?>
        <?php echo $form->error($loginForm,'username'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($loginForm,'password'); ?>
        <?php echo $form->passwordField($loginForm,'password'); ?>
        <?php echo $form->error($loginForm,'password'); ?>
    </div>

    <div class="row rememberMe">
        <?php echo $form->checkBox($loginForm,'rememberMe'); ?>
        <?php echo $form->label($loginForm,'rememberMe'); ?>
        <?php echo $form->error($loginForm,'rememberMe'); ?>
    </div>


    <div class="row buttons">
        <?php echo CHtml::submitButton(Yii::t('common', 'Login')); ?>
    </div>

    <?php $this->endWidget(); ?>
</div>
<?php endif; ?>