Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non-crispy checkbox #3182

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
stveit marked this conversation as resolved.
Show resolved Hide resolved
{% 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>
Loading