Yii Framework Forum: Default validator options - how?! - Yii Framework Forum

Jump to content

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

Default validator options - how?! CStringValidator.encoding=>'utf-8' Rate Topic: -----

#1 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 28 April 2010 - 05:24 AM

There is no way to set some properties to validator, that would applied to all validators of same type (CStringValidator.encoding='utf-8' for example), or am I wrong?! Any suggestions? :rolleyes:
-Posted Image-
Thanks, you make me stronger!
0

#2 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 28 April 2010 - 06:06 AM

Maybe by overriding the validateAttribute() method in CStringValidator and add your validation code
0

#3 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 28 April 2010 - 09:11 AM

View PostSpyros, on 28 April 2010 - 06:06 AM, said:

Maybe by overriding the validateAttribute() method in CStringValidator and add your validation code


I know how to solve my problem, by using overriding and customization of validators, but I try to find the way to do it using internal features, without customization.
-Posted Image-
Thanks, you make me stronger!
0

#4 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 28 April 2010 - 12:54 PM

Following your logic, there should be a static property "encoding", but this disallow to set this property per validator.

I think, in your situation extending CStringValidator class is a good idea. You won't need to set encoding somewhere (and then forget, where :) ) in your application, all common settings will be stored in the validator class.
0

#5 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 28 April 2010 - 01:01 PM

View Postandy_s, on 28 April 2010 - 12:54 PM, said:

Following your logic, there should be a static property "encoding", but this disallow to set this property per validator.

I think, in your situation extending CStringValidator class is a good idea. You won't need to set encoding somewhere (and then forget, where :) ) in your application, all common settings will be stored in the validator class.


"good" idea, but project almost completed, + all "length" validators without "encoding" property...
-Posted Image-
Thanks, you make me stronger!
0

#6 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 28 April 2010 - 01:22 PM

Turn on mbstring function overloading in php.ini (mbstring.func_overload = 7). http://php.net/manua...ng.overload.php
0

#7 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 28 April 2010 - 01:31 PM

thx it's really good solution :) (but if i didn't have access to production php.ini?) ::)
-Posted Image-
Thanks, you make me stronger!
0

#8 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 28 April 2010 - 01:42 PM

View Postvamp, on 28 April 2010 - 01:31 PM, said:

thx it's really good solution :) (but if i didn't have access to production php.ini?) ::)


Maybe possible through htaccess if you use Apache.
0

#9 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,358
  • Joined: 12-October 09
  • Location:Croatia

Posted 28 April 2010 - 03:34 PM

If you didn't have access to the php.ini and if the server is strict enough that you cannot set this in htaccess, the only way would be to change the existing code unfortunately :(
Find more about me.... btw. Do you know your WAN IP?
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