Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hshassets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
django
hshassets
Commits
3dbb95f6
There was an error fetching the commit references. Please try again later.
Commit
3dbb95f6
authored
7 years ago
by
Tim Fechner
Browse files
Options
Downloads
Patches
Plain Diff
Don't output empty <label for=""> attributes
parent
eb75b520
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hshassets/forms/utils.py
+8
-2
8 additions, 2 deletions
hshassets/forms/utils.py
with
8 additions
and
2 deletions
hshassets/forms/utils.py
+
8
−
2
View file @
3dbb95f6
...
...
@@ -8,6 +8,7 @@ def render_form_field(field):
input_type
=
field
.
field
.
widget
.
input_type
except
AttributeError
:
input_type
=
None
if
input_type
in
[
'
text
'
,
'
number
'
,
'
email
'
,
'
url
'
,
'
password
'
]:
# one of those text-like that support icons
out
=
BulmaFieldMarkup
.
label
(
field
.
label
,
BulmaFieldMarkup
.
with_icons
(
field
,
field
.
as_widget
()))
...
...
@@ -17,6 +18,7 @@ def render_form_field(field):
else
:
# fallback default
out
=
BulmaFieldMarkup
.
label
(
field
.
label
,
BulmaFieldMarkup
.
div_control
(
field
.
as_widget
()))
return
BulmaFieldMarkup
.
div_field
(
field
,
out
)
...
...
@@ -43,7 +45,12 @@ class BulmaFieldMarkup(object):
@classmethod
def
label
(
cls
,
label
,
content
=
''
,
css_class
=
'
label
'
,
for_id
=
''
):
"""
Define <label> seperately so it can be used elsewhere instead as a children of the <div class=
"
field
"
>
"""
if
for_id
:
return
format_html
(
'
<label for=
"
{}
"
class=
"
{}
"
>{}</label> {}
'
,
for_id
,
css_class
,
label
,
content
)
else
:
# don't output a empty for="" attribute as it breaks some form functionality
return
format_html
(
'
<label class=
"
{}
"
>{}</label> {}
'
,
css_class
,
label
,
content
)
@classmethod
def
with_icons
(
cls
,
field
,
content
):
...
...
@@ -126,4 +133,3 @@ def render_form_errors(errors):
"""
,
error_tags
=
error_tags
,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment