Yii Framework Forum: Cjuidialog/cactiveform Client-Side Validation Problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cjuidialog/cactiveform Client-Side Validation Problem Few browsers outputs error message after dialog loaded Rate Topic: -----

#1 User is offline   YuraDoc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-January 13

Posted 24 January 2013 - 01:18 PM

Hello.
Let me describe my problem. I think that this problem relates more to jQuery UI, but I want to discuss it with Yii community, maybe we'll find right decision.
I have a form, that is copy of standart login form generated by Yii. I placed it in jQuery UI dialog using CJuiDialog. In CActiveForm I had add "'enableClientValidation'=>true". It works good in Firefox and Opera, but other browsers shows errors after Username field and highlights it. I think that blur event called after loading in browser.
I did found only one way for temporarily resolving this problem, when create event of the dialog occurs:
if($.browser.webkit || $.browser.msie){
  var isHandlerActive = false;
  $("#LoginForm_username").blur(function(e) {
    if (!isHandlerActive)
      e.stopImmediatePropagation();
      isHandlerActive = true;
  });
}


Full listing here of the view:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
                'options'=>array(
                    'title'=>'Login',
                    'autoOpen'=>true,
                    'modal'=>true,
                    'show'=>'puff',
                    'hide'=>'slide',
                    'width'=>'350',
                    'height'=>'auto',
                    //'focusSelector' => 'submit',
                    'create'=> 'js:function(event, ui) {
                      if($.browser.webkit || $.browser.msie){
                        var isHandlerActive = false;
                        $("#LoginForm_username").blur(function(e) {
                          if (!isHandlerActive)
                            e.stopImmediatePropagation();
                          isHandlerActive = true;
                        });
                      }
                    }'
                ),
                ));
?>

<p>Please fill out the following form with your login credentials:</p>

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'login-form',
	'enableClientValidation'=>true,
	'clientOptions'=>array(
		'validateOnSubmit'=>true,
	),
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<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'); ?>
		<p class="hint">
			Hint: You may login with <tt>demo/demo</tt> or <tt>admin/admin</tt>.
		</p>
	</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 buttons">
		<?php echo CHtml::submitButton('Login'); ?>
	</div>

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

<?php $this->endWidget('zii.widgets.jui.CJuiDialog');?>


May somebody could provide nature interpretation of the work in such way in Chrome, Safari, IE. Maybe there are better ways for resolving. And may we include temporarily resolving of this pb in the Yii core and make request in jQuery UI community, if this is js bug only.

Thanks, Yuriy.

Attached File(s)

  • Attached File  login.png (13.92K)
    Number of downloads: 11

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users