Yii Framework Forum: Any Chance For Dynamic Add/remove Rules - Yii Framework Forum

Jump to content

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

Any Chance For Dynamic Add/remove Rules

#1 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 744
  • Joined: 02-February 09

Posted 23 October 2013 - 04:47 PM

Is there any chance we can see more dynamic manipulation of validation rules in Yii2. Something like $model->addValidationRule() / $model->removeValidationRule() on the fly? This will simplify the rules logic tremendously in complex situations and shouldn't be an overhead for the overall application.
0

#2 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 360
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 23 October 2013 - 04:55 PM

Model::getValidators() returns an ArrayObject instance that you can manipulate as you like.
This also works for yii1.1 via CModel::getValidatorList() where you get a Clist object.
0

#3 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 744
  • Joined: 02-February 09

Posted 23 October 2013 - 05:25 PM

Ah... I've totally missed this. Thanks CeBe
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