Setting a form field's value during validation
- by LaundroMat
I read about this issue already, but I'm having trouble understanding why I can't change the value of a form's field during validation.
I have a form where a user can enter a decimal value. This value has to be higher than the initial value of the item the user is changing. During clean(), the value that was entered is checked against the item's previous value. I would like to be able to re-set the form field's value to the item's initial value when a user enters a lower value.
Is this possible from within the clean() method, or am I forced to do this in the view? Somehow, it doesn't feel right to do this in the view...
(To make matters more complicated, the form's fields are built up dynamically, meaning I have to override the form's clean() method instead of using the clean_() method).