1

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?

boadescriptor
  • 735
  • 2
  • 9
  • 29

2 Answers2

2

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.

boadescriptor
  • 735
  • 2
  • 9
  • 29
1

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

gawel
  • 2,038
  • 14
  • 16
  • This changes the value of field.parent.model.SOMEOTHERFIELD but the change is not committed to the db if I do `session.commit()`... How do I commit the change to the DB? – boadescriptor Mar 29 '12 at 17:34