Yii Framework Forum: Yii 1.1.13 Trim Error - Yii Framework Forum

Jump to content

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

Yii 1.1.13 Trim Error Rate Topic: -----

#1 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 11 May 2013 - 06:51 AM

I added trim filter in model
array('name','unique'),
array('name','filter','filter'=>'trim'),

In form
When i gave this type of input " yii " [space in front], The below error is occured
Error:
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Visitors' for key 'name'. The SQL statement executed was: INSERT INTO `visitors_type` (`name`, `isactive`) VALUES (:yp0, :yp1)
0

#2 User is offline   luk1999 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 20-April 11
  • Location:Poland

Posted 11 May 2013 - 11:50 AM

Unique validator doesn't work, because it must be declared after filter.
Check this: http://www.yiiframew...dpost__p__83031

View Posttsolar, on 28 February 2011 - 10:29 AM, said:

Hi all

I almost ask something without a try, but maybe this helps to someone...

i had
array('area', 'required'),
array('area', 'unique'),
array('area', 'filter', 'filter'=>'trim'),

but the unique validation was not occurring.

So I put the unique validation after the trim filter and it worked:
array('area', 'required'),
array('area', 'filter', 'filter'=>'trim'),
array('area', 'unique'),

Cheers

Happy hacking!

0

#3 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 16 May 2013 - 05:02 AM

View Postluk1999, on 11 May 2013 - 11:50 AM, said:

Unique validator doesn't work, because it must be declared after filter.
Check this: http://www.yiiframew...dpost__p__83031

Thank you
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