Skip to content

Commit dea9026

Browse files
committed
fix styling issues + allow restrict custom
1 parent c9b6e95 commit dea9026

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

app/templates/macros/form_macros.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@
9393
{% endfor %}
9494
</div>
9595
</div>
96-
<script>
97-
$(document).ready(function() {
98-
$('div#{{field.name}}').dropdown({
99-
allowAdditions: true
100-
})
101-
});
102-
</script>
96+
{% if field.allow_custom %}
97+
<script>
98+
$(document).ready(function() {
99+
$('div#{{field.name}}').dropdown({
100+
allowAdditions: true
101+
})
102+
});
103+
</script>
104+
{% endif %}
103105
{% endmacro %}
104106

105107
{# Render a field for the form #}

app/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from wtforms.widgets import HiddenInput
44
from wtforms.compat import text_type
55

6+
67
def register_template_utils(app):
78
"""Register Jinja 2 helpers (called from __init__.py)."""
89

@@ -25,10 +26,12 @@ def index_for_role(role):
2526
class CustomSelectField(Field):
2627
widget = HiddenInput()
2728

28-
def __init__(self, label='', validators=None, multiple=False, choices=[], **kwargs):
29+
def __init__(self, label='', validators=None, multiple=False,
30+
choices=[], allow_custom=True, **kwargs):
2931
super(CustomSelectField, self).__init__(label, validators, **kwargs)
3032
self.multiple = multiple
3133
self.choices = choices
34+
self.allow_custom = allow_custom
3235

3336
def _value(self):
3437
return text_type(self.data) if self.data is not None else ''

0 commit comments

Comments
 (0)