Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Marks An Attribute Unsafe For Mass Assignment.

$
0
0
Hi,

I have a special custom validator (without class, only function) in model and I want to mark an attribute as unsafe. I tried with below code but the unsafe validator does not mark it as unsafe. with scenarios works properly (and may should follow this approach) but I have already wrote a lot of code and adding scenarios for each line may make my website unstable...


 public function myCustomValidatorCondition($attribute, $params) {
        if (...some condition...) {
             $valid = CValidator::createValidator( 'boolean', $this, array($attribute));
             $valid->validate($this);
        } else {
             $valid = CValidator::createValidator( 'unsafe', $this, array($attribute));
             $valid->validate($this);
        }
    }


I also noted that each validator has $safe variable to mark (?) the attribute as unsafe. how can I use this for τhe above purpose?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>