Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
0881fdb6
Commit
0881fdb6
authored
6 years ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
Taking into accound CharFieldDataList
parent
2db67b7e
No related branches found
No related tags found
1 merge request
!1
Wizard form
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ippisite/ippidb/templatetags/customtags.py
+16
-1
16 additions, 1 deletion
ippisite/ippidb/templatetags/customtags.py
with
16 additions
and
1 deletion
ippisite/ippidb/templatetags/customtags.py
+
16
−
1
View file @
0881fdb6
...
...
@@ -3,6 +3,7 @@ import logging
from
django
import
forms
from
django
import
template
from
django.utils.safestring
import
mark_safe
from
django.utils.translation
import
ugettext
register
=
template
.
Library
()
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -55,10 +56,25 @@ def bootstrap(object):
# overwrite the css classes
attrs
[
"
class
"
]
=
"
"
.
join
(
css_classes
)
if
'
datalist
'
in
attrs
:
datalist
=
attrs
.
pop
(
"
datalist
"
)
attrs
[
"
list
"
]
=
"
list__%s
"
%
field
.
id_for_label
else
:
datalist
=
None
# render the field
ret
.
append
(
'
<div class=
"
%s
"
>
'
%
wrapping_classes
)
ret
.
append
(
field
.
as_widget
(
attrs
=
attrs
))
ret
.
append
(
"""
<label class=
"
%s
"
>%s</label>
"""
%
(
label_classes
,
field
.
label
))
# If the field has a datalist attribut the input field will suggest from it, printing the element
if
datalist
:
ret
.
append
(
'
<datalist id=
"
%s
"
>
'
%
attrs
[
"
list
"
])
for
option
in
datalist
:
ret
.
append
(
'
<option value=
"
%s
"
>
'
%
option
)
ret
.
append
(
'
</datalist>
'
)
if
help_text
:
ret
.
append
(
"""
<small class =
"
form-text text-muted
"
>%s</small>
"""
%
help_text
)
if
field
.
errors
:
...
...
@@ -69,7 +85,6 @@ def bootstrap(object):
# return it as safe html code
elif
isinstance
(
object
,
forms
.
BaseFormSet
):
formset
=
object
print
(
formset
.
errors
)
for
error
in
formset
.
non_form_errors
():
ret
.
append
(
"""
<div class=
"
alert alert-danger
"
>%s</div>
"""
%
error
.
replace
(
"
\n
"
,
"
<br/>
"
))
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