mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 05:29:43 +02:00
fixed the 'other' problem in requesting entity form
This commit is contained in:
parent
fabeddaa61
commit
74ef30b52d
2 changed files with 10 additions and 9 deletions
|
@ -38,11 +38,6 @@ export function handleRequestingEntityFieldset() {
|
||||||
requestingNewSuborganization.value === "True" ? showElement(suborgDetailsContainer) : hideElement(suborgDetailsContainer);
|
requestingNewSuborganization.value === "True" ? showElement(suborgDetailsContainer) : hideElement(suborgDetailsContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add fake "other" option to sub_organization select
|
|
||||||
if (select && !Array.from(select.options).some(option => option.value === "other")) {
|
|
||||||
select.add(new Option(subOrgCreateNewOption, "other"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requestingNewSuborganization.value === "True") {
|
if (requestingNewSuborganization.value === "True") {
|
||||||
select.value = "other";
|
select.value = "other";
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,13 +63,19 @@ class RequestingEntityForm(RegistrarForm):
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Override of init to add the suborganization queryset"""
|
"""Override of init to add the suborganization queryset and 'other' option"""
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
if self.domain_request.portfolio:
|
if self.domain_request.portfolio:
|
||||||
self.fields["sub_organization"].queryset = Suborganization.objects.filter(
|
# Fetch the queryset for the portfolio
|
||||||
portfolio=self.domain_request.portfolio
|
queryset = Suborganization.objects.filter(portfolio=self.domain_request.portfolio)
|
||||||
)
|
# set the queryset appropriately so that post can validate against queryset
|
||||||
|
self.fields["sub_organization"].queryset = queryset
|
||||||
|
|
||||||
|
# Modify the choices to include "other" so that form can display options properly
|
||||||
|
self.fields["sub_organization"].choices = [("", "--Select--")] + [
|
||||||
|
(obj.id, str(obj)) for obj in queryset
|
||||||
|
] + [("other", "Other (enter your suborganization manually)")]
|
||||||
|
|
||||||
def clean_sub_organization(self):
|
def clean_sub_organization(self):
|
||||||
"""On suborganization clean, set the suborganization value to None if the user is requesting
|
"""On suborganization clean, set the suborganization value to None if the user is requesting
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue