Force Write Back data bindings

Continuing the discussion from Data binding not refreshing:

Is there a simple way to have data bindings with write back enabled forced to update self.item with out processing the pressed_enter or lost_focus events? Docs explanation below.

Write Back does not trigger when self.refresh_data_bindings() is called, when self.init_components(**properties) is called or when the self.item for the Form is set. It only triggers when events such as pressed_enter fire on the relevant component.

In some of my forms, self.item does not have some keys added to it when the user doesn’t click on all textboxes or date pickers. I know that I can set it in code or dummy run the events but I was wondering if there is a cleaner way?

In that situation, I often set self.item to a dict with all the necessary keys (and placeholder values) during the form’s unit.

Similarly, rather than setting the placeholder/default values in the UI IDE and looking to write those initial values back to self.item, I set the initial default values via data bindings to a self.item dictionary, inspired by this guideline (but instead of passing an empty dictionary to self.item for a Create record, I pass a default item, defined in the appropriate module).

2 Likes