Yii Framework Forum: Username availability checker - Yii Framework Forum

Jump to content

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

Username availability checker Rate Topic: ****- 1 Votes

#1 User is offline   jbomhold3 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 06-May 10

Posted 11 May 2010 - 01:30 AM

I'm sure this is easy but can't find it. What class handles the in page username availability checker like the one the forum has. An example would be nice to.
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 11 May 2010 - 01:34 AM

You mean the unique validation rule?

http://www.yiiframew...alidation-rules
http://www.yiiframew...UniqueValidator
0

#3 User is offline   jbomhold3 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 06-May 10

Posted 11 May 2010 - 01:40 AM

I got that part. I want to do exactly like the forum does green box around it if it is good without having to submit.
0

#4 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 11 May 2010 - 01:53 AM

Did you check CActiveForm? It can be configured to do what you want.
0

#5 User is offline   jbomhold3 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 06-May 10

Posted 11 May 2010 - 02:12 AM

Trying to get it working now.
0

#6 User is offline   jbomhold3 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 06-May 10

Posted 11 May 2010 - 02:46 AM

Got it working kinda. I understand how to send errors but how do I tell it good or set the border color on the field.

public function unique(){
$username = $this->username;
if ($this->username != ""){
$user=User::model()->find('username=?',array($username));
if($user===null){
}
else {
$this->addError('username','Username already in use');
}
}
}

protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='EmployeeAddForm')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}


<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username'); ?>
<?php echo $form->error($model,'username'); ?>
0

#7 User is offline   jbomhold3 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 06-May 10

Posted 11 May 2010 - 03:22 AM

Nevermind.... Need to do this stuff while i'm not tired so I can read better sorry.
///////////Edit////////////
Related
Can you text the value of a input field using performAjaxValidation. Like if a enter last name Smith and it finds Bob for the first name it sets the input field firstname to Bob, or am i getting out side of built in functions now.
0

#8 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 11 May 2010 - 05:19 AM

AFAIK not possible with ActiveForm.
0

#9 User is offline   jbomhold3 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 06-May 10

Posted 11 May 2010 - 12:14 PM

Ok cool have the Java made for that already. Was just hoping yii had it by default.
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