Saving into database

Hello every one

I generated simple model and the table name User. Table as couple of fields but two main ones are user name ans password. The model also has CRUD implemented but once I am going to generate new user and save the password into database with MD5().

Can someone tell me how to manipulate the data from user before saving and then how to save it?


You can use beforeSave trigger in model.

The befoewSave didnt work but afterValidated worked. Really dont know why beforeSave didint work

It could be that you spelled beforeSave wrong. Above you have it spelled befoewSave.

Thank you

I tried beforeSave() with correct spelling but still does not work. afterValidate() is the only function seems working

Make sure you call the parent function and that you return true:


protected function beforeSave()



      // your code      

      return true;