Module: ActionView::Helpers::FormOptionsHelper
- Defined in:
- lib/currency_select.rb
Overview
Module for the form options.
Instance Method Summary collapse
-
#currency_options_for_select(selected = nil, priority_currencies = nil) ⇒ Object
Returns a string of option tags for all available currencies.
-
#currency_select(object, method, priority_currencies = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using currency_options_for_select to generate the list of option tags.
Instance Method Details
#currency_options_for_select(selected = nil, priority_currencies = nil) ⇒ Object
Returns a string of option tags for all available currencies. Supply a currency ISO code as selected to have it marked as the selected option tag. You can also supply an array of currencies as priority_currencies, so that they will be listed above the rest of the list.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/currency_select.rb', line 93 def (selected = nil, priority_currencies = nil) = ''.html_safe if priority_currencies += ( ::CurrencySelect.priority_currencies_array(priority_currencies), selected ) raw = '<option value="" disabled="disabled">-------------</option>' += raw.html_safe + "\n" # prevents selected from being included twice in the HTML which causes # some browsers to select the second selected option (not priority) # which makes it harder to select an alternative priority country selected = nil if priority_currencies.include?(selected) end # All the countries included in the country_options output. + ( ::CurrencySelect.currencies_array, selected ) end |
#currency_select(object, method, priority_currencies = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using currency_options_for_select to generate the list of option tags.
80 81 82 83 84 85 86 |
# File 'lib/currency_select.rb', line 80 def currency_select( object, method, priority_currencies = nil, = {}, = {} ) tag = CurrencySelectTag.new(object, method, self, ) tag.to_currency_select_tag(priority_currencies, , ) end |