Hi guys, i’m having a problem with two validation rules (default, value=>null and filter strip_tags), i cannot use the same attribute with this two validation rules. If i set default null and strip tags, the default rule don’t work. Someone have any idea why this happen?
I think you are making some confusion about the ‘default’ and ‘filter’ validators! If you read the
CDefaultValueValidator, you can check that it does not do any validation but only allows to set a default value at the time validation is performed. About the CFilterValidator, you can read that this validator transforms the data being validated based on a filter. So, basically, how this works?
Imagine this example: you have a database table called tbl_user, with the field ‘username’, and you want to ensure that, if the user don’t enter any data into this field, the application saves the default value ‘guest’ or something else, if the user type something, you want to ensure that the data is saved without any HTML or PHP tags, ie if the user enter ‘<p>ohohoh</p>’ the value that going to be save is ‘ohohoh’, otherwise (an empty value) the value that is going to be saved is ‘guest’.