fix phone number country code on address form (#130)

This commit is contained in:
nora 2025-12-23 13:42:09 -05:00 committed by GitHub
parent 3aec5f6692
commit f43e8a0ec6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -55,11 +55,11 @@ Element.prototype.attachShadow = function(init) {
return originalAttachShadow.call(this, init);
};
function createAddressAutocomplete() {
function createAddressAutocomplete(initialData = {}) {
return {
callingCodes: {},
callingCode: '1',
selectedCountry: 'US',
callingCodes: initialData.callingCodes || {},
callingCode: initialData.callingCode || '1',
selectedCountry: initialData.selectedCountry || 'US',
init() {
if (window.googleMapsReady) {

View file

@ -27,7 +27,7 @@
form_html_attrs = {}
end
%>
<%= form_with model: address, url: local_assigns[:url], local: true, html: form_html_attrs.merge("x-data": "addressAutocomplete", "@alpine:init": "Object.assign($data, { callingCodes: #{country_calling_codes.to_json}, callingCode: '#{initial_calling_code}', selectedCountry: '#{initial_country}' })") do |f| %>
<%= form_with model: address, url: local_assigns[:url], local: true, html: form_html_attrs.merge("x-data": "addressAutocomplete(#{({ callingCodes: country_calling_codes, callingCode: initial_calling_code, selectedCountry: initial_country }).to_json})") do |f| %>
<% if local_assigns[:from_program] %>
<%= f.hidden_field :from_program, value: true %>
<% end %>