Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
8250d8a7
Commit
8250d8a7
authored
Jul 31, 2014
by
Julian Gonggrijp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add on_form_prefill hook to BaseModelView
parent
8d7b0a50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
base.py
flask_admin/model/base.py
+25
-0
No files found.
flask_admin/model/base.py
View file @
8250d8a7
...
@@ -965,6 +965,29 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -965,6 +965,29 @@ class BaseModelView(BaseView, ActionsMixin):
By default do nothing.
By default do nothing.
"""
"""
pass
pass
def
on_form_prefill
(
self
,
form
,
id
):
"""
Perform additional actions to pre-fill the edit form.
Called from edit_view, if the current action is rendering
the form rather than receiving client side input, after
default pre-filling has been performed.
By default does nothing.
You only need to override this if you have added custom
fields that depend on the database contents in a way that
Flask-admin can't figure out by itself. Fields that were
added by name of a normal column or relationship should
work out of the box.
:param form:
Form instance
:param id:
id of the object that is going to be edited
"""
pass
def
create_model
(
self
,
form
):
def
create_model
(
self
,
form
):
"""
"""
...
@@ -1307,6 +1330,8 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -1307,6 +1330,8 @@ class BaseModelView(BaseView, ActionsMixin):
else
:
else
:
return
redirect
(
return_url
)
return
redirect
(
return_url
)
self
.
on_form_prefill
(
form
,
id
)
form_opts
=
FormOpts
(
widget_args
=
self
.
form_widget_args
,
form_opts
=
FormOpts
(
widget_args
=
self
.
form_widget_args
,
form_rules
=
self
.
_form_edit_rules
)
form_rules
=
self
.
_form_edit_rules
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment