Yii Framework Forum: Conditional rules in Yii? - Yii Framework Forum

Jump to content

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

Conditional rules in Yii? Rate Topic: -----

#1 User is offline   yiiti 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 06-May 16

Posted 23 June 2016 - 05:16 PM

I would like to increase the length of name when there is a numerical string attached at the end of the campaign name like '_232231'. Is there an elegant way to do this in Yii?
    $rules = array(
        array('name', 'length', 'min'=>5,'max'=>36),
    );

0

#2 User is offline   Patrick Jones 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 227
  • Joined: 14-July 12
  • Location:Berlin

Posted 23 June 2016 - 05:43 PM

This might be the most elegant way:
www.yiiframework.com/doc-2.0/guide-input-validation.html#creating-validators
Life begins outside the comfort zone.
0

#3 User is offline   oligalma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 418
  • Joined: 07-April 12
  • Location:Spain

Posted 28 June 2016 - 10:11 PM

You can create a validator easily. In the following link there is a clear example, in which the validator "checkUniqueness" is created.

http://www.yiiframew...ultiple-columns
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