title: Custom validation filter on yii2
body: <p>I need to filter data that come from hmtl form from html tags, quotes etc.</p>
  
  <p>It seems that I need to write my own filter callback function according to <a href="http://www.yiiframework.com/doc-2.0/yii-validators-filtervalidator.html" rel="nofollow">http://www.yiiframework.com/doc-2.0/yii-validators-filtervalidator.html</a> . I got these rules in my model:</p>
  
  <pre><code> public function rules()
      {
          return [
              [['name', 'email', 'phone',], 'required'],
              [['course'], 'string',],
              [['name', 'email', 'phone',], 'string', 'max'=&gt;250],
              ['email', 'email'],
              [['name', 'email', 'phone'], function($value){
                  return trim(htmlentities(strip_tags($value), ENT_QUOTES, 'UTF-8'));
              }],
  
          ];
      }
  </code></pre>
  
  <p>Last rule is my own filter that i added. But it is not working. Tags, spaces, qoutes don't remove from and this filter is not even running. How to achieve what i want and what i'm doing wrong? </p>
  
  <p>Thank you</p>