Skip to content

Commit

Permalink
Merge pull request Uninett#3182 from Uninett/uncrispify/add-non-crisp…
Browse files Browse the repository at this point in the history
…y-checkbox

Add non-crispy checkbox
  • Loading branch information
stveit authored Nov 13, 2024
2 parents f6bb3f3 + 549e4c5 commit 9db1bbf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions python/nav/web/crispyforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ class CheckBox(Field):
template = 'custom_crispy_templates/horizontal_checkbox.html'


class FormCheckBox:
"""Checkbox suited for the NAV layout
:param field: A field to render as a checkbox field.
"""

def __init__(self, field):
self.field = field
self.input_type = 'checkbox'


class HelpField(Field):
"""Field that displays an icon with tooltip as helptext"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
{% include 'custom_crispy_templates/submit_field.html' with input=field %}
{% elif field.input_type == 'helpfield' %}
{% include 'custom_crispy_templates/field_helptext_as_icon.html' with field=field.field %}
{% elif field.input_type == 'checkbox' %}
{% include 'custom_crispy_templates/form_checkbox.html' with field=field.field %}
{% else %}
{% show_field field %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div id="div_{{ field.auto_id }}" class="ctrlHolder{% if field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<label for="{{ field.id_for_label }}">
{{ field.label}}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
{{ field }}
</label>
{% for error in field.errors %}
<small id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="errorField">
{{ error }}
</small>
{% endfor %}
</div>

0 comments on commit 9db1bbf

Please sign in to comment.