How to update a form field value using conditions?