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
716307f8
Commit
716307f8
authored
Oct 22, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/bakatrouble/flask-admin
into sqlalchemy-utils-types
parents
1f172b3e
cad758e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
fields.py
flask_admin/form/fields.py
+11
-1
No files found.
flask_admin/form/fields.py
View file @
716307f8
...
@@ -117,6 +117,13 @@ class Select2Field(fields.SelectField):
...
@@ -117,6 +117,13 @@ class Select2Field(fields.SelectField):
self
.
allow_blank
=
allow_blank
self
.
allow_blank
=
allow_blank
self
.
blank_text
=
blank_text
or
' '
self
.
blank_text
=
blank_text
or
' '
try
:
from
sqlalchemy_utils.types.choice
import
Choice
except
ImportError
:
class
Choice
(
object
):
pass
self
.
choice_cls
=
Choice
def
iter_choices
(
self
):
def
iter_choices
(
self
):
if
self
.
allow_blank
:
if
self
.
allow_blank
:
yield
(
u'__None'
,
self
.
blank_text
,
self
.
data
is
None
)
yield
(
u'__None'
,
self
.
blank_text
,
self
.
data
is
None
)
...
@@ -129,7 +136,10 @@ class Select2Field(fields.SelectField):
...
@@ -129,7 +136,10 @@ class Select2Field(fields.SelectField):
self
.
data
=
None
self
.
data
=
None
else
:
else
:
try
:
try
:
self
.
data
=
self
.
coerce
(
value
)
if
isinstance
(
value
,
self
.
choice_cls
):
self
.
data
=
self
.
coerce
(
value
.
code
)
else
:
self
.
data
=
self
.
coerce
(
value
)
except
(
ValueError
,
TypeError
):
except
(
ValueError
,
TypeError
):
self
.
data
=
None
self
.
data
=
None
...
...
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