You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that while you can pass sqlalchemy orm objects to widgets as values and have them rendered nicely, if there are validation errors the value is changed to a list of dictionaries. This can cause issues when interacting with the value in the prepare function as well as in validators because accessing dictionary values is different than how you access object properties. Not sure how to handle this but wanted to bring the point up to see if anyone else has noticed this and has any workarounds, or if I am just not doing things correctly.
The text was updated successfully, but these errors were encountered:
An example is I have a grid layout that is rendering a sqlalchemy relation that is a list of objects and I am trying to sort this list in the prepare function on three keys. When sorting you can use itemgetter or attrgetter depending on if you are sorting a list of dictionaries or list of objects. If I use attrgetter because it is a list of objects and the user submits the form which is rejected as invalid (for what ever reason), now I get an error that it can't sort the list as the list is now a list of dictionaries (as to list of objects when initially rendered in a valid state). I often find I have to have conditionals for all forms to check the data type before accessing properties.
It seems that while you can pass sqlalchemy orm objects to widgets as values and have them rendered nicely, if there are validation errors the value is changed to a list of dictionaries. This can cause issues when interacting with the value in the prepare function as well as in validators because accessing dictionary values is different than how you access object properties. Not sure how to handle this but wanted to bring the point up to see if anyone else has noticed this and has any workarounds, or if I am just not doing things correctly.
The text was updated successfully, but these errors were encountered: