0

I want to attach a behavior to a validator defined in the rules() function of a form. I can not figure out how. If I do something like this

array('page',  'numerical', 'integerOnly' => true, 'min' => 1, 'message' => '{attribute} is invalid'
    , 'behaviors' => array( 
        'error' => array( 'class' => 'CErrorBehavior'),
        ),
    ),

I get the following exception

Property "CNumberValidator.behaviors" is not defined.

Any ideas?

goto
  • 433
  • 3
  • 13
  • 1
    The `CValidator` class doesn't expose behaviors like that. You could overload [`CModel::createValidators`](http://www.yiiframework.com/doc/api/1.1/CModel#createValidators-detail) and set behaviors explicitly in there. – DCoder Nov 24 '12 at 06:51
  • What are you want to do? – Sergey Nov 26 '12 at 05:09
  • I want to add an error property without extending the CValidator class as it would mean that I have to "rewrite" standard validators – goto Nov 27 '12 at 05:52

0 Answers0