Add sublabels and nonfunctional add-another button

This commit is contained in:
Neil Martinsen-Burrell 2023-05-01 15:44:20 -05:00
parent 6d83add0e5
commit 56df44643e
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
3 changed files with 20 additions and 2 deletions

View file

@ -18,6 +18,7 @@
{{ formset.management_form }}
{% for form in formset %}
{% with sublabel_text="Example: ns"|concat:forloop.counter|concat:".nameserver.com" %}
{% if forloop.counter <= 2 %}
{% with attr_required=True %}
{% input_with_errors form.server %}
@ -25,9 +26,17 @@
{% else %}
{% input_with_errors form.server %}
{% endif %}
{% endwith %}
{% endfor %}
<button
<button type="submit" name="submit_button" value="save" class="usa-button usa-button--unstyled display-block">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#add_circle"></use>
</svg><span class="margin-left-05">Add another name server</span>
</button>
<button
type="submit"
class="usa-button"
>Save</button>

View file

@ -28,6 +28,10 @@ error messages, if necessary.
{% include "django/forms/label.html" %}
{% endif %}
{% if sublabel_text %}
<p id="{{ widget.attrs.id }}__sublabel" class="text-base">{{ sublabel_text }}</p>
{% endif %}
{% if field.errors %}
<div id="{{ widget.attrs.id }}__error-message">
{% for error in field.errors %}
@ -71,4 +75,4 @@ error messages, if necessary.
</span>
</div>
{% endif %}
{% endif %}

View file

@ -6,3 +6,8 @@ from django.template.defaulttags import register
@register.filter
def get_item(dictionary, key):
return dictionary.get(key)
@register.filter
def concat(arg1, arg2):
"""concatenate arg1 & arg2"""
return str(arg1) + str(arg2)