mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
angular_options_for_select
This commit is contained in:
@@ -23,22 +23,4 @@ class AngularFormBuilder < ActionView::Helpers::FormBuilder
|
||||
def angular_select(method, choices, options = {}, html_options = {})
|
||||
# ...
|
||||
end
|
||||
|
||||
def angular_options_for_select(container, selected = nil)
|
||||
return container if String === container
|
||||
|
||||
selected, disabled = extract_selected_and_disabled(selected).map do | r |
|
||||
Array.wrap(r).map { |item| item.to_s }
|
||||
end
|
||||
|
||||
container.map do |element|
|
||||
html_attributes = option_html_attributes(element)
|
||||
text, value = option_text_and_value(element).map { |item| item.to_s }
|
||||
selected_attribute = %Q( ng-selected="#{selected}") if selected
|
||||
disabled_attribute = ' disabled="disabled"' if disabled && option_value_selected?(value, disabled)
|
||||
%(<option value="#{ERB::Util.html_escape(value)}"#{selected_attribute}#{disabled_attribute}#{html_attributes}>#{ERB::Util.html_escape(text)}</option>)
|
||||
end.join("\n").html_safe
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user