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
4e652448
Commit
4e652448
authored
7 years ago
by
Art
Browse files
Options
Downloads
Patches
Plain Diff
Fix render_form_field()
parent
c3003f89
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
hshassets/forms/utils.py
+10
-7
10 additions, 7 deletions
hshassets/forms/utils.py
hshassets/templatetags/bulma.py
+1
-0
1 addition, 0 deletions
hshassets/templatetags/bulma.py
with
11 additions
and
7 deletions
hshassets/forms/utils.py
+
10
−
7
View file @
4e652448
...
@@ -4,14 +4,17 @@ from django.template import defaulttags
...
@@ -4,14 +4,17 @@ from django.template import defaulttags
def
render_form_field
(
field
):
def
render_form_field
(
field
):
if
field
.
field
.
widget
.
input_type
in
[
'
text
'
,
'
number
'
,
'
email
'
,
'
url
'
,
'
password
'
]:
try
:
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
# one of those text-like that support icons
out
=
BulmaFieldMarkup
.
label
(
field
.
label
,
BulmaFieldMarkup
.
with_icons
(
field
,
field
.
as_widget
()))
out
=
BulmaFieldMarkup
.
label
(
field
.
label
,
BulmaFieldMarkup
.
with_icons
(
field
,
field
.
as_widget
()))
elif
input_type
and
getattr
(
BulmaFieldMarkup
,
input_type
,
None
):
# something else explicitly defined
out
=
getattr
(
BulmaFieldMarkup
,
input_type
)(
field
,
field
.
as_widget
())
else
:
else
:
try
:
# something implemented explicitly
out
=
getattr
(
BulmaFieldMarkup
,
field
.
field
.
widget
.
input_type
)(
field
,
field
.
as_widget
())
except
AttributeError
:
# fallback default
# fallback default
out
=
BulmaFieldMarkup
.
label
(
field
.
label
,
BulmaFieldMarkup
.
div_control
(
field
.
as_widget
()))
out
=
BulmaFieldMarkup
.
label
(
field
.
label
,
BulmaFieldMarkup
.
div_control
(
field
.
as_widget
()))
return
BulmaFieldMarkup
.
div_field
(
field
,
out
)
return
BulmaFieldMarkup
.
div_field
(
field
,
out
)
...
...
This diff is collapsed.
Click to expand it.
hshassets/templatetags/bulma.py
+
1
−
0
View file @
4e652448
...
@@ -32,6 +32,7 @@ def bulma_form_fields(form):
...
@@ -32,6 +32,7 @@ def bulma_form_fields(form):
def
bulma_form_errors
(
form
):
def
bulma_form_errors
(
form
):
return
render_form_errors
([
str
(
e
)
for
e
in
form
.
non_field_errors
()])
return
render_form_errors
([
str
(
e
)
for
e
in
form
.
non_field_errors
()])
@register.simple_tag
(
takes_context
=
True
)
@register.simple_tag
(
takes_context
=
True
)
def
bulma_form
(
context
,
form
,
submit_text
=
"
OK
"
,
submit_class
=
"
button is-outlined
"
):
def
bulma_form
(
context
,
form
,
submit_text
=
"
OK
"
,
submit_class
=
"
button is-outlined
"
):
"""
Renders whole form, including errors, csrf and a submit button.
"""
"""
Renders whole form, including errors, csrf and a submit button.
"""
...
...
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