Yii Framework Forum: Staring Valdiater ? How To Add - Yii Framework Forum

Jump to content

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

Staring Valdiater ? How To Add Rate Topic: -----

#1 User is offline   samilo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 231
  • Joined: 04-October 12

Posted 09 December 2012 - 01:44 AM

Hi All

I had in my form filed for username how to add type for it in model just to accept string ?

Like in int we can add :
numerical', 'integerOnly'=>true


Thanks in advance
0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,083
  • Joined: 16-February 11
  • Location:Japan

Posted 09 December 2012 - 02:34 AM

Probably what you want to use is "match" ... CRegularExpressionValidator.

Look at the reference.
http://www.yiiframew...essionValidator
And there are some comments that include usage samples.
1

#3 User is offline   samilo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 231
  • Joined: 04-October 12

Posted 09 December 2012 - 04:26 AM

Yes that is , Thank you my bro :)


array('username', 'match', 'pattern'=>'/^([a-z0-9_])+$/'),

0

#4 User is offline   Azy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 156
  • Joined: 16-May 12

Posted 10 December 2012 - 05:36 AM

This way also possible if you want to match types.

array('distance', 'type', 'type'=>'float', 'message'=>'should be a valid number.' )


http://www.yiiframew.../CTypeValidator

View Postsamilo, on 09 December 2012 - 04:26 AM, said:

Yes that is , Thank you my bro :)


array('username', 'match', 'pattern'=>'/^([a-z0-9_])+$/'),


1

#5 User is offline   samilo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 231
  • Joined: 04-October 12

Posted 11 December 2012 - 01:15 AM

Thanks Little Man :)




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