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
a8e3bc54
"step/email/lib.php" did not exist on "273af1eef7367d74ca1e20052201b84de203b8b8"
Commit
a8e3bc54
authored
7 years ago
by
Art
Browse files
Options
Downloads
Patches
Plain Diff
Tag bulmaform now updates widget attrs instead of resetting them.
parent
256e6f86
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hshassets/templatetags/bulma.py
+8
-4
8 additions, 4 deletions
hshassets/templatetags/bulma.py
with
8 additions
and
4 deletions
hshassets/templatetags/bulma.py
+
8
−
4
View file @
a8e3bc54
...
@@ -11,13 +11,17 @@ register = template.Library()
...
@@ -11,13 +11,17 @@ register = template.Library()
def
bulmaform
(
form
):
def
bulmaform
(
form
):
"""
Templatetag to render forms with bulma styles and elements
"""
"""
Templatetag to render forms with bulma styles and elements
"""
# because the <input> tag will be rendered by django's internals, it is easier to give the widgets
# append bulma css classes to widgets and let django render these widgets
# a css-class rather than render every <input> tag by mysqlf
for
field
in
form
:
for
field
in
form
:
widget_classes
=
list
()
# not every form element in bulma has the 'input' css class, so we need to differ here
# not every form element in bulma has the 'input' css class, so we need to differ here
if
getattr
(
field
.
field
.
widget
,
'
input_type
'
,
None
)
not
in
[
'
checkbox
'
,
'
radio
'
]:
if
getattr
(
field
.
field
.
widget
,
'
input_type
'
,
None
)
not
in
[
'
checkbox
'
,
'
radio
'
]:
field
.
field
.
widget
.
attrs
=
{
'
class
'
:
'
input
'
+
(
'
is-danger
'
if
field
.
errors
else
''
)}
widget_classes
.
append
(
"
input
"
)
# highlight fields with errors
if
field
.
errors
:
widget_classes
.
append
(
"
is-danger
"
)
# done
field
.
field
.
widget
.
attrs
[
"
class
"
]
=
"
"
.
join
(
widget_classes
)
if
getattr
(
form
,
'
layout
'
,
None
):
if
getattr
(
form
,
'
layout
'
,
None
):
output
=
render_layout
(
form
.
layout
,
form
)
output
=
render_layout
(
form
.
layout
,
form
)
else
:
else
:
...
...
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