Write the rules in a model's Rules method,
public function rules() { return [ [['title','description','keywords'],'strip_tags'] ]; }
This is supposed to be the same as the trim function, the content is filtered, in fact, the error
Reflectionexception
Class Strip_tags does not exist
Why use trim as a function, but strip_tags as a class, what's going on?
Reply content:
Write the rules in a model's Rules method,
public function rules() { return [ [['title','description','keywords'],'strip_tags'] ]; }
This is supposed to be the same as the trim function, the content is filtered, in fact, the error
Reflectionexception
Class Strip_tags does not exist
Why use trim as a function, but strip_tags as a class, what's going on?
is not treated as a trim
function.
public static $builtInValidators = [' Boolean ' = ' yii\validators\booleanvalidator ', ' captcha ' = ' Yii\captcha\captchavalidator ', ' compare ' = ' yii\validators\comparevalidator ', ' date ' = ' Yii\validat Ors\datevalidator ', ' default ' = ' yii\validators\defaultvaluevalidator ', ' double ' = ' yii\validators\n ' Umbervalidator ', ' each ' = ' yii\validators\eachvalidator ', ' email ' = ' yii\validators\emailvalidator ', ' Exist ' = ' yii\validators\existvalidator ', ' file ' = ' yii\validators\filevalidator ', ' filter ' = ' yii\validators\filtervalidator ', ' image ' = ' yii\validators\imagevalidator ', ' in ' = ' Yii\vali ' Dators\rangevalidator ', ' integer ' = [' class ' = ' yii\validators\numbervalidator ', ' in Tegeronly ' = True,], ' match ' = ' yii\validators\regularexpressionvalidator ', ' number ' = ' Yii\validators\numbervalIdator ', ' required ' = ' yii\validators\requiredvalidator ', ' safe ' = ' yii\validators\safevalidator ', ' String ' = ' yii\validators\stringvalidator ', ' trim ' and ' = ' class ' + ' yii\validators\filt Ervalidator ', ' filter ' = ' trim ', ' skiponarray ' = = True,], ' unique ' = ' yii\ ' Validators\uniquevalidator ', ' url ' = ' yii\validators\urlvalidator ', ' ip ' = = ' Yii\validators\ipvalidat or ',];
The parent class yii/base/model::createvalidators, the landlord can see this method concretely, generate the validator method.
Traversing rules, judging $rule[1], is also equivalent to ' trim ', ' strip_tags ' these fields
1, whether it is an anonymous function ($rule instanceof \Closure)
or whether it is a subclass of methods
2. Determine if an existing authenticator is present
public static $builtInValidators = [' Boolean ' = ' yii\validators\booleanvalidator ', ' captcha ' = ' yii ' \captcha\captchavalidator ', ' compare ' = ' yii\validators\comparevalidator ', ' date ' = ' yii\validators\ Datevalidator ', ' default ' = ' yii\validators\defaultvaluevalidator ', ' double ' = ' Yii\validators\numbe ' Rvalidator ', ' each ' = ' yii\validators\eachvalidator ', ' email ' = ' yii\validators\emailvalidator ', ' Exist ' = ' yii\validators\existvalidator ', ' file ' = ' yii\validators\filevalidator ', ' Filter ' =&G T ' Yii\validators\filtervalidator ', ' image ' = ' yii\validators\imagevalidator ', ' in ' = ' yii\validators\ ' RangeValidator ', ' integer ' = [' class ' = ' Yii\validators\numbervalidator ', ' Integeron Ly ' = True,], ' match ' = ' yii\validators\regularexpressionvalidator ', ' number ' = ' yii\val Idators\numbervalidator ', ' required ' = ' yii\validators\requiredvalidator ', ' safe ' = ' yii\validators\safevalidator ', ' String ' = ' yii\validators\stringvalidator ', ' trim ' and ' = ' class ' + ' Yii\validators\filterva Lidator ', ' filter ' = ' trim ', ' skiponarray ' = = True,], ' unique ' = ' Yii\vali ' Dators\uniquevalidator ', ' url ' = ' yii\validators\urlvalidator ',];