removed default empty options from Checkboxes as they are only needed for Selects

This commit is contained in:
David Kennedy 2025-01-17 17:38:00 -05:00
parent 3708ef1672
commit ba2788014b
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
4 changed files with 6 additions and 11 deletions

View file

@ -15,7 +15,6 @@ export function handleRequestingEntityFieldset() {
const suborgContainer = document.getElementById("suborganization-container");
const suborgDetailsContainer = document.getElementById("suborganization-container__details");
const suborgAddtlInstruction = document.getElementById("suborganization-addtl-instruction");
const subOrgCreateNewOption = document.getElementById("option-to-add-suborg")?.value;
// Make sure all crucial page elements exist before proceeding.
// This more or less ensures that we are on the Requesting Entity page, and not elsewhere.
if (!radios || !input || !select || !inputGrandParent || !suborgContainer || !suborgDetailsContainer) return;
@ -28,7 +27,7 @@ export function handleRequestingEntityFieldset() {
function toggleSuborganization(radio=null) {
if (radio != null) requestingSuborganization = radio?.checked && radio.value === "True";
requestingSuborganization ? showElement(suborgContainer) : hideElement(suborgContainer);
if (select.options.length == 2) { // --Select-- and other are the only options
if (select.options.length == 1) { // other is the only option
hideElement(inputGrandParent); // Hide the combo box and indicate requesting new suborg
hideElement(suborgAddtlInstruction); // Hide additional instruction related to the list
requestingNewSuborganization.value = "True";

View file

@ -450,7 +450,6 @@ class DomainOrgNameAddressForm(forms.ModelForm):
label="Federal agency",
required=False,
queryset=FederalAgency.objects.all(),
empty_label="--Select--",
widget=ComboboxWidget,
)
zipcode = forms.CharField(
@ -469,7 +468,7 @@ class DomainOrgNameAddressForm(forms.ModelForm):
state_territory = forms.ChoiceField(
label="State, territory, or military post",
required=True,
choices=[("", "--Select--")] + DomainInformation.StateTerritoryChoices.choices,
choices=DomainInformation.StateTerritoryChoices.choices,
error_messages={
"required": ("Select the state, territory, or military post where your organization is located.")
},

View file

@ -44,7 +44,6 @@ class RequestingEntityForm(RegistrarForm):
label="Suborganization name",
required=False,
queryset=Suborganization.objects.none(),
empty_label="--Select--",
widget=ComboboxWidget,
)
requested_suborganization = forms.CharField(
@ -58,7 +57,7 @@ class RequestingEntityForm(RegistrarForm):
suborganization_state_territory = forms.ChoiceField(
label="State, territory, or military post",
required=False,
choices=[("", "--Select--")] + DomainRequest.StateTerritoryChoices.choices,
choices=DomainRequest.StateTerritoryChoices.choices,
widget=ComboboxWidget,
)
@ -74,8 +73,7 @@ class RequestingEntityForm(RegistrarForm):
# 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]
[(obj.id, str(obj)) for obj in queryset]
+ [("other", "Other (enter your suborganization manually)")]
)
@ -328,7 +326,6 @@ class OrganizationContactForm(RegistrarForm):
# uncomment to see if modelChoiceField can be an arg later
required=False,
queryset=FederalAgency.objects.exclude(agency__in=excluded_agencies),
empty_label="--Select--",
widget=ComboboxWidget,
)
organization_name = forms.CharField(
@ -349,7 +346,7 @@ class OrganizationContactForm(RegistrarForm):
)
state_territory = forms.ChoiceField(
label="State, territory, or military post",
choices=[("", "--Select--")] + DomainRequest.StateTerritoryChoices.choices,
choices=DomainRequest.StateTerritoryChoices.choices,
error_messages={
"required": ("Select the state, territory, or military post where your organization is located.")
},

View file

@ -37,7 +37,7 @@ class PortfolioOrgAddressForm(forms.ModelForm):
state_territory = forms.ChoiceField(
label="State, territory, or military post",
required=True,
choices=[("", "--Select--")] + DomainInformation.StateTerritoryChoices.choices,
choices=DomainInformation.StateTerritoryChoices.choices,
error_messages={
"required": ("Select the state, territory, or military post where your organization is located.")
},