How to calculate fields inside of the form?