I have a simple setup in Yii with a Model, View and a Controller to manage a DB table. (created with Gii)
When the user presses the delete button I want to validate this request with some rules of my own and if there is an error display this to the user.
Should I put validation method in the Model, call this validation from the controller delete method. But then I am not sure how I get a popup to appear on the webpage.
I can’t speak specifically for Yii, but in general with PHP 5.3 a good practice would be to throw errors from models (mind you, human readable ones) and then catch them when you call the models in your controllers. The controllers can then pass along a list of errors to the views, which would be responsible for displaying the error(s) to the users.