A normal form works, but I like ajax forms.
I added this code
<div class="form">
<?php $form = $this->beginWidget('CActiveForm', array(
'id'=>'login-form',
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'clientOptions'=> array('validateOnSubmit'=>true),
));
?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username'); ?>
<?php echo $form->error($model,'username'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password'); ?>
<?php echo $form->error($model,'password'); ?>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model,'rememberMe'); ?>
<?php echo $form->label($model,'rememberMe'); ?>
<?php echo $form->error($model,'rememberMe'); ?>
</div>
<div class="row submit">
<?php echo CHtml::submitButton('Login'); ?>
<?php
echo CHtml::ajaxSubmitButton('Login2', 'site/login');
?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
in the controller
if(Yii::app()->request->isAjaxRequest)
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
When i push login2 I see from firebug that I get in response
{"LoginForm_username":["\u041b\u043e\u0433\u0438\u043d: cannot be blank."],"LoginForm_password":["\u041f\u0430\u0440\u043e\u043b\u044c: cannot be blank.","Incorrect username or password."]}
But nothing happens in the form…
I just don’t get how it works, I created zillion forms with ajax, this tool is waste of time for my now… hope I will understand and it will actually save time as it should(or maybe not ?)