I want to have some kind of filter on all of my text fields on my application, to know if a field has some bad content, like filter out bad mouthing of users.
I have thought of some ways
- I could
preg_replace()
overphp://input
stream, and replace bad content - I could write a custom filter and put it for every single field in every model, which is a LOTand I really don't want to go there
- I could some how override default sting validator of yii ( I don't know how to do that... yet)
I want to do that in a dynamic way and don't want to write a lot of rules
what is the best solution for my situation( from above or any other)?
Update: I'm looking for a way to replace cursing and swearing from the users input and replace it with something else
Hope this is what you are asking
You want to remove
Scripts
in the FieldsTags
in the fields, etcYou can go with the Yii Input Extension. It removes unwanted data from the user's data.
You have two ways to do it
config/main.php
In case done globally and when you use some
CKEditor
ortinyeditor
you wont get required html posted. But then you have methods to get them alsoEDIT:
Your case is to remove the unwanted words in the Users input
so
This can be once in all the controller (sure this would work).
(NOT TRIED) Another way is to have it in the parent controller which is
Controller