From d797ef2b3aead8da39471decadf9782459744a8c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 13 Oct 2022 15:12:06 +0200 Subject: [PATCH] As we are in the Business Address panel, use the business_address attr Not the address one, which is different Business address country could be null, so use an empty array --- app/views/admin/enterprises/form/_business_address.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/admin/enterprises/form/_business_address.html.haml b/app/views/admin/enterprises/form/_business_address.html.haml index 793b71307f..784754b873 100644 --- a/app/views/admin/enterprises/form/_business_address.html.haml +++ b/app/views/admin/enterprises/form/_business_address.html.haml @@ -33,7 +33,8 @@ .four.columns = bf.select :country_id, options_for_select(available_countries.map { |c| [c.name, c.id] }, @enterprise.business_address.country_id), {}, { "data-controller": "tom-select", "data-dependent-select-target": "source", "data-action": "dependent-select#handleSelectChange", class: "primary" } .four.columns.omega - = bf.select :state_id, @enterprise.address.country.states.map { |s| [s.name, s.id] }, {}, { "data-controller": "tom-select", "data-dependent-select-target": "select", class: "primary" } + - states = @enterprise.business_address.country.present? ? @enterprise.business_address.country&.states&.map { |s| [s.name, s.id] } : [] + = bf.select :state_id, states, {}, { "data-controller": "tom-select", "data-dependent-select-target": "select", class: "primary" } .row .three.columns.alpha