문제

Writing custom validators for Formalchemy is simple. During the validation of SOMEFIELD I can access another fields value using field.parent.SOMEOTHERFIELD.value.

Is it possible to change SOMEOTHERFIELD's value during the validation of SOMEFIELD? Or should I separate changing related field values from the validation process altogether?

도움이 되었습니까?

해결책

gawel's answer was a step but did not solve my problem (see comment under his answer). I changed the value of field.parent.model.SOMEOTHERFIELD but the change was not committed to the db with session.commit().

After trying out many things I found out that you must use fieldset.sync() before field.parent.model.SOMEOTHERFIELD = value. Only then the change is committed.

다른 팁

You can use field.parent.model.SOMEOTHERFIELD = value

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top