Calculate a value based on two other fields before saving
I have a simple quantity field, price field and I can't figure out how to calculate a total field where I will hide it on the creating and updating. When I create a record I would like to take say quantity of 10 and price of 5 and total would be saved as 50. I know this should be easily doable but can't seem to get it to work. I tried a resolvedUsing with no luck and also a Mutator on the Model with no luck. Any tips to lead me down the right path would be appreciated. ideally without installing an outside package to accomplish it. I don't care about it showing in real time on the front end.
I have similar question: I have a table with result of the runners. In column 'margin' I'm saving value beetween runners, in column 'total_margin' I'm saving margin beetween winner and other next runners. So, every time I edit result row, I have to input margin, and add this value to last saved value from 'total_margin', and save. I think the last value from 'total_margin' column have to be restricted to result_id. Otherwise last value will be delivered to next result. Any idea?