Which is recieved in the Controller class like follows,
$model->attributes = $_POST['Users'];
Thats then saved to a database. What I want to know is if the user enters something like " /me" for their name how do I get it into "me". I basically want to get rid of any leading whitespaces and any unwanted characters like / - , ; etc. I have tried adding the following into the Model class but It did not work.
Hey, that works great for certain parts of the project but would you know a way in which only leading and trailing empty spaces are stripped from the form. Eg if someone types " Hello there " is there a way to either throw up and error about the spaces or could you change that to "Hello there". So basically get rid of the spaces at the start and the end but keep any spaces between words.
Hey that does seem like a useful function and normally this would pose no problems to implement but how do I implement it in yii. In the rules section or in the controller? Thanks for your help.
As this is something that you could utilise in other models/forms, my advise would be to create your own filter and use that as a callback to a filter ‘rule’ in the model. Otherwise, you may find yourself repeating code.