Display name rather than id

This commit is contained in:
zandercymatics 2024-08-05 09:15:55 -06:00
parent a1c63a809d
commit 6a0412d872
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 10 additions and 2 deletions

View file

@ -191,6 +191,10 @@ class DomainSuborganizationForm(forms.ModelForm):
# Use the combobox rather than the regular select widget
self.fields["sub_organization"].widget.template_name = "django/forms/widgets/combobox.html"
def get_suborganization_name(self):
"""Returns the suborganization name for the readonly view"""
return self.instance.sub_organization if self.instance else None
class BaseNameserverFormset(forms.BaseFormSet):

View file

@ -23,7 +23,7 @@
</form>
{% else %}
{% with description="The suborganization for this domain can only be updated by a organization administrator."%}
{% include "includes/input_read_only.html" with field=form.sub_organization label_description=description%}
{% include "includes/input_read_only.html" with field=form.sub_organization value=instance.get_suborganization_name label_description=description%}
{% endwith %}
{% endif %}

View file

@ -7,4 +7,8 @@ Template include for read-only form fields
{% if label_description %}
<p class="usa-hint margin-top-0 margin-bottom-05">{{ label_description }}</p>
{% endif %}
<p class="read-only-value">{{ field.value }}</p>
{% comment %}
This allows us to customize the displayed value.
For instance, Select fields will display the id by default.
{% endcomment %}
<p class="read-only-value">{{ value|default:field.value }}</p>