1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-28 17:49:38 +02:00

Enable all currencies for preferences (#722)

This commit is contained in:
Zach Gollwitzer 2024-05-07 16:19:00 -04:00 committed by GitHub
parent 1c2950462f
commit 79789bd696
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 28 deletions

View file

@ -74,6 +74,20 @@ class ApplicationFormBuilder < ActionView::Helpers::FormBuilder
end
end
def currency_select(method, options = {}, html_options = {})
default_options = { class: "form-field__input" }
merged_options = default_options.merge(html_options)
choices = currency_options_for_select
return @template.grouped_collection_select(@object_name, method, choices, :last, :first, :last, :first, options, merged_options) unless options[:label]
@template.form_field_tag do
label(method, *label_args(options)) +
@template.grouped_collection_select(@object_name, method, choices, :last, :first, :last, :first, options, merged_options.except(:label))
end
end
def select(method, choices, options = {}, html_options = {})
default_options = { class: "form-field__input" }
merged_options = default_options.merge(html_options)

View file

@ -7,7 +7,7 @@
<div>
<%= form_with model: Current.user, url: settings_preferences_path, html: { class: "space-y-4", data: { controller: "auto-submit-form" } } do |form| %>
<%= form.fields_for :family_attributes do |family_fields| %>
<%= family_fields.select :currency, options_for_select(Money::Currency.popular.map { |currency| ["#{currency.iso_code} (#{currency.name})", currency.iso_code] }, selected: Current.family.currency), { label: "Currency" }, { data: { auto_submit_form_target: "auto" } } %>
<%= family_fields.currency_select :currency, { selected: Current.family.currency, label: "Currency" }, { data: { auto_submit_form_target: "auto" } } %>
<% end %>
<% end %>
</div>