Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions flask_appbuilder/baseviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ def _add(self):
item = self.datamodel.obj()

try:
form.populate_obj(item)
self.populate_item_from_form(form, item, True)
self.pre_add(item)
except Exception as e:
flash(str(e), "danger")
Expand Down Expand Up @@ -1266,7 +1266,7 @@ def _edit(self, pk):
self.process_form(form, False)

try:
form.populate_obj(item)
self.populate_item_from_form(form, item, False)
self.pre_update(item)
except Exception as e:
flash(str(e), "danger")
Expand Down Expand Up @@ -1380,6 +1380,13 @@ def is_get_mutation_allowed(self) -> bool:
request.method == "GET" and self.appbuilder.app.extensions.get("csrf")
)

def populate_item_from_form(self, form, item, is_created):
"""
Populate the properties of the item to be created or updated based
on the content of the form.
"""
form.populate_obj(item)

def prefill_form(self, form, pk):
"""
Override this, will be called only if the current action is rendering
Expand Down