Login Form In Modal

Guys

when I click on login button or sign in button. a modal appears and when someone enters email and password and click on sign in , it closes the modal.

i want that the modal doesnot close and the error appears on the modal dialog.

<div class="modal-body">

<!-- Sign In Form -->

<!–/* @var $model User/validated via CUserIdentity */

/* @var $form CActiveForm */–>

<!-- Text input–>

<?php echo CHtml::beginForm(array(‘class’=>‘form-horizontal’)); ?>

<div class="form-group">

<?php echo CHtml::errorSummary($model); ?>

<div class="control-group">

<label class="control-label" for="Email">Email:</label>

<div class="controls">

<?php echo CHtml::activeTextField($model,‘Email’,array(‘class’=>‘form-control’,‘id’=>‘Email’,‘placeholder’=>‘yourname@email.com’)) ?>

</div>

</div>

<!-- Password input–>

<div class="control-group">

<label class="control-label" for="password">Password:</label>

<div class="controls">

<?php echo CHtml::activePasswordField($model,‘password’,array(‘class’=>‘form-control’,‘id’=>‘password’,‘type’=>‘password’ ,‘class’=>‘input-large’,‘placeholder’=>’********’)) ?>

</div><!–controls–>

</div><!–control-group–>

<!-- Remember me -->

<div class="control-group">

<label class="checkbox inline" for="rememberme-0">Remember me

<?php echo CHtml::activeCheckBox($model,‘rememberMe’,array(‘type’=>‘checkbox’,‘name’=>‘Rememberme’,‘id’=>‘rememberme-0’,‘value’=>‘Remember me’)); ?>

</label>

</div><!–control-group–>

<!-- Sign in button -->

<div class="control-group">

<label class="control-label" for="signin"></label>

<div class="controls">

<?php echo CHtml::submitButton(‘Login’,array(‘id’=>‘Signin’,‘name’=>‘signin’, ‘class’=>‘btn btn-success’)); ?>

</div><!–controls–>

</div><!–control-group–>

</div>

<?php echo CHtml::endForm(); ?>

0

enable ajax validation in your form first you have to change your CHtml::beginForm to CActiveForm widget


// replace this 

<?php echo CHtml::beginForm(array('class'=>'form-horizontal')); ?>

// with this

<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'login-form',

	'enableClientValidation'=>true, // enabled

	'clientOptions'=>array(

		'validateOnSubmit'=>true,

	),

)); ?>

Thanks For the Reply.

I have enabled Client Side validations.

But the problem is , when I click on Sign in , the modal disappears and when I click on Sign in again, the modal appears (but this time with the error messages for validations)

So I want that when I click on sign in , the modal should not disappear, but it should stay in its state , unless I click on close button.

appreciate your help in this!

try this I have not tested it I don’t have dev machine at disposal at the moment


<?php $form=$this->beginWidget('CActiveForm', array(

        'id'=>'login-form',

        'enableClientValidation'=>true, // enabled

)); ?>

Tried implementing it, i am not able to get the client side validation done. help