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
e26e4185
Commit
e26e4185
authored
Jul 22, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #259. Do not highlight field if its children have error
parent
a0a3a7f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
helpers.py
flask_admin/helpers.py
+16
-0
lib.html
flask_admin/templates/admin/lib.html
+4
-3
No files found.
flask_admin/helpers.py
View file @
e26e4185
from
flask
import
g
,
request
from
wtforms.validators
import
DataRequired
,
InputRequired
from
._compat
import
string_types
def
set_current_view
(
view
):
g
.
_admin_view
=
view
...
...
@@ -53,3 +55,17 @@ def get_form_data():
return
formdata
return
None
def
is_field_error
(
errors
):
"""
Check if wtforms field has direct error.
:param errors:
Errors list.
"""
for
e
in
errors
:
if
isinstance
(
e
,
string_types
):
return
True
return
False
flask_admin/templates/admin/lib.html
View file @
e26e4185
...
...
@@ -76,7 +76,8 @@
{# ---------------------- Forms -------------------------- #}
{% macro render_field(form, field, set_focus=False, kwargs={}) %}
<div
class=
"control-group{{ ' error' if field.errors else '' }}"
>
{% set direct_error = h.is_field_error(field.errors) %}
<div
class=
"control-group{{ ' error' if direct_error else '' }}"
>
<div
class=
"control-label"
>
{{ field.label.text }}
{% if h.is_required_form_field(field) %}
...
...
@@ -96,8 +97,8 @@
{% if field.description %}
<p
class=
"help-block"
>
{{ field.description }}
</p>
{% endif %}
{% if
field.errors
%}
<ul
class=
"input-errors"
>
{% if
direct_error
%}
<ul
{%
if
direct_error
%}
class=
"input-errors"
{%
endif
%}
>
{% for e in field.errors if e is string %}
<li>
{{ e }}
</li>
{% endfor %}
...
...
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