After using the code provided in the following comment https://stackoverflow.com/a/13518727/3159370 , I would like to access model attributes and change them before the model gets saved.
If you're curious why I want to do that, I think it's the best way to convert empty(varchar) 0(integer) to null before saving it in the database.
EDIT: What am looking for is a generic method to loop through all the attributes.