Class: Decidim::LegacyFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Decidim::LegacyFormBuilder
- Includes:
- ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper
- Defined in:
- decidim-core/lib/decidim/legacy_form_builder.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#autocomplete(attribute, url, options = {}) ⇒ Object
rubocop:enable Metrics/ParameterLists.
-
#collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #date_select(attribute, options = {}, html_options = {}) ⇒ Object
- #datetime_select(attribute, options = {}, html_options = {}) ⇒ Object
- #error_for(attribute, options = {}) ⇒ Object
- #label(attribute, text = nil, options = {}) ⇒ Object
- #radio_button(attribute, tag_value, options = {}) ⇒ Object
- #select(attribute, choices, options = {}, html_options = {}) ⇒ Object
- #submit(value = nil, options = {}) ⇒ Object
- #time_zone_select(attribute, priorities = nil, options = {}, html_options = {}) ⇒ Object
Instance Method Details
#autocomplete(attribute, url, options = {}) ⇒ Object
rubocop:enable Metrics/ParameterLists
81 82 83 84 85 86 87 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 81 def autocomplete(attribute, url, = {}) field attribute, do |opts| opts.merge!(update_elements: opts[:update_elements], min_length: 0, value: object.send(attribute)) autocomplete_field(attribute, url, opts) end end |
#collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
rubocop:disable Metrics/ParameterLists
72 73 74 75 76 77 78 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 72 def collection_select(attribute, collection, value_method, text_method, = {}, = {}) field attribute, , do |html_opts| [:autocomplete] ||= :off super(attribute, collection, value_method, text_method, , html_opts) end end |
#date_select(attribute, options = {}, html_options = {}) ⇒ Object
51 52 53 54 55 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 51 def date_select(attribute, = {}, = {}) field attribute, , do |html_opts| super(attribute, , html_opts.merge(autocomplete: :off)) end end |
#datetime_select(attribute, options = {}, html_options = {}) ⇒ Object
45 46 47 48 49 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 45 def datetime_select(attribute, = {}, = {}) field attribute, , do |html_opts| super(attribute, , html_opts.merge(autocomplete: :off)) end end |
#error_for(attribute, options = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 94 def error_for(attribute, = {}) return unless error?(attribute) class_name = "form-error is-visible" class_name += " #{options[:class]}" if [:class] = object.errors[attribute].join(", ") = .html_safe if [:html_safe_errors] content_tag(:small, , class: class_name.sub("is-invalid-input", "")) end |
#label(attribute, text = nil, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 25 def label(attribute, text = nil, = {}) if error?(attribute) [:class] ||= "" [:class] += " is-invalid-label" end super(attribute, (text || "").html_safe, ) end |
#radio_button(attribute, tag_value, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 34 def (attribute, tag_value, = {}) [:label_options] ||= {} = .delete(:label_options)&.merge!(value: tag_value) label_text = .delete(:label) l = label(attribute, label_text, ) unless label_text == false r = @template.(@object_name, attribute, tag_value, ()) "#{r}#{l}".html_safe end |
#select(attribute, choices, options = {}, html_options = {}) ⇒ Object
64 65 66 67 68 69 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 64 def select(attribute, choices, = {}, = {}) field attribute, , do |html_opts| [:autocomplete] ||= :off super(attribute, choices, , html_opts) end end |
#submit(value = nil, options = {}) ⇒ Object
89 90 91 92 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 89 def submit(value = nil, = {}) [:class] ||= "button" super end |
#time_zone_select(attribute, priorities = nil, options = {}, html_options = {}) ⇒ Object
57 58 59 60 61 62 |
# File 'decidim-core/lib/decidim/legacy_form_builder.rb', line 57 def time_zone_select(attribute, priorities = nil, = {}, = {}) field attribute, , do |html_opts| super(attribute, priorities, , html_opts.merge(autocomplete: :off)) end end |