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
cf3a95c1
Commit
cf3a95c1
authored
Dec 16, 2016
by
antoine.lizee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enh: keep allow_blank=False for MANYTOONE that are required
parent
f7825f99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
form.py
flask_admin/contrib/sqla/form.py
+7
-6
No files found.
flask_admin/contrib/sqla/form.py
View file @
cf3a95c1
...
...
@@ -105,15 +105,16 @@ class AdminModelConverter(ModelConverterBase):
# determine optional/required, or respect existing
requirement_options
=
(
validators
.
Optional
,
validators
.
InputRequired
)
if
not
any
(
isinstance
(
v
,
requirement_options
)
for
v
in
kwargs
[
'validators'
]):
if
property_is_association_proxy
or
column
.
nullable
or
prop
.
direction
.
name
!=
'MANYTOONE'
:
requirement_validator_specified
=
any
(
isinstance
(
v
,
requirement_options
)
for
v
in
kwargs
[
'validators'
])
if
property_is_association_proxy
or
column
.
nullable
or
prop
.
direction
.
name
!=
'MANYTOONE'
:
kwargs
[
'allow_blank'
]
=
True
if
not
requirement_validator_specified
:
kwargs
[
'validators'
]
.
append
(
validators
.
Optional
())
else
:
else
:
kwargs
[
'allow_blank'
]
=
False
if
not
requirement_validator_specified
:
kwargs
[
'validators'
]
.
append
(
validators
.
InputRequired
())
# Never prepopulate relation widgets:
kwargs
[
'allow_blank'
]
=
True
# Override field type if necessary
override
=
self
.
_get_field_override
(
prop
.
key
)
if
override
:
...
...
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