I am facing a problem of inserting a data into a field. This field is is a sum from several fields in the same table. It should be working for new entry and also update.
Am I to create beforeSave() function in model? Or should I use afterSave(), grab the fields to add and insert into a field?
Example: A is the sum of fields B, C and D (I need to insert this into a field)
You should use beforeSave(). In case of afterSave, you will need to save model again which in turn will make recursive calls to afterSave which will cause troubles for you.
Creating a new record or updating works fine. My main question is how do i actually get the values from a form and add it? It needs to sum up and save in the database field.