Class: Arara::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Arara::FormBuilder
- Includes:
- ActionView::Helpers::FormTagHelper
- Defined in:
- app/components/arara/form_builder.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #chip_choice(method, options = {}, &block) ⇒ Object
- #chip_filter(method, options = {}, &block) ⇒ Object
- #chipset_choice(method, options = {}, &block) ⇒ Object
- #chipset_filter(method, options = {}, &block) ⇒ Object
- #country_select(method, priority_or_options = {}, options = {}, html_options = {}) ⇒ Object
- #label(method, options = {}) ⇒ Object
- #password_field(method, options = {}) ⇒ Object
- #radio_button(method, tag_value, options = {}) ⇒ Object
- #select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
- #submit(value = nil, options = {}) ⇒ Object
- #text_area(method, options = {}) ⇒ Object
- #text_field(method, options = {}) ⇒ Object
Instance Attribute Details
#template ⇒ Object (readonly)
Returns the value of attribute template.
3 4 5 |
# File 'app/components/arara/form_builder.rb', line 3 def template @template end |
Instance Method Details
#check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/components/arara/form_builder.rb', line 53 def check_box(method, = {}, checked_value = "1", unchecked_value = "0") .deep_stringify_keys! ["label"] = .fetch("label") { build_label(method, ) } # options["has_error"] = has_errors_for?(method) # options["helper_text"] = errors_for(method).join(", ") Tags::CheckBox.new(object_name, method, self, checked_value, unchecked_value, ()).render end |
#chip_choice(method, options = {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'app/components/arara/form_builder.rb', line 21 def chip_choice(method, = {}, &block) .deep_stringify_keys! ["variant"] = :choice checked_value = [:value].to_s unchecked_value = 0 [:include_hidden] = false Tags::ChipChoice.new(object_name, method, self, checked_value, unchecked_value, (), &block).render end |
#chip_filter(method, options = {}, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/components/arara/form_builder.rb', line 41 def chip_filter(method, = {}, &block) .deep_stringify_keys! ["variant"] = :filter checked_value = [:value].to_s unchecked_value = 0 [:include_hidden] = true [:multiple] = true Tags::ChipChoice.new(object_name, method, self, checked_value, unchecked_value, (), &block).render end |
#chipset_choice(method, options = {}, &block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/components/arara/form_builder.rb', line 12 def chipset_choice(method, = {}, &block) .deep_stringify_keys! ["variant"] = :choice [:data] ||= {} [:data][:controller] = "rails-chip-set-choice" Tags::Chipset.new(object_name, method, self, (), &block).render end |
#chipset_filter(method, options = {}, &block) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/components/arara/form_builder.rb', line 32 def chipset_filter(method, = {}, &block) .deep_stringify_keys! ["variant"] = :filter [:data] ||= {} [:data][:controller] = "rails-chip-set-filter" Tags::Chipset.new(object_name, method, self, (), &block).render end |
#country_select(method, priority_or_options = {}, options = {}, html_options = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/components/arara/form_builder.rb', line 102 def country_select(method, = {}, = {}, = {}) .deep_stringify_keys! if Hash === = = else [:priority_countries] = end ["label"] = .fetch("label") { build_label(method, ) } Tags::CountrySelect.new(object_name, method, self, (), @default_options.merge()).render end |
#label(method, options = {}) ⇒ Object
7 8 9 10 |
# File 'app/components/arara/form_builder.rb', line 7 def label(method, = {}) .deep_stringify_keys! super(method, ) end |
#password_field(method, options = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'app/components/arara/form_builder.rb', line 71 def password_field(method, = {}) .deep_stringify_keys! ["label"] = .fetch("label") { build_label(method, ) } ["has_error"] = has_errors_for?(method) ["helper_text"] = errors_for(method).join(", ") ["type"] = "password" Tags::PasswordField.new(object_name, method, self, ()).render end |
#radio_button(method, tag_value, options = {}) ⇒ Object
97 98 99 100 |
# File 'app/components/arara/form_builder.rb', line 97 def (method, tag_value, = {}) .deep_stringify_keys! Tags::RadioButton.new(object_name, method, self, tag_value, ()).render end |
#select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
90 91 92 93 94 95 |
# File 'app/components/arara/form_builder.rb', line 90 def select(method, choices = nil, = {}, = {}, &block) .deep_stringify_keys! ["label"] = .fetch("label") { build_label(method, ) } Tags::Select.new(object_name, method, self, choices, (), (), &block).render end |
#submit(value = nil, options = {}) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'app/components/arara/form_builder.rb', line 115 def submit(value = nil, = {}) .deep_stringify_keys! value, = nil, value if value.is_a?(Hash) value ||= submit_default_value = .deep_stringify_keys = { "type" => "submit", "name" => "commit", "value" => value }.update() set_default_disable_with value, @template.render(ButtonComponent, .symbolize_keys) end |
#text_area(method, options = {}) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'app/components/arara/form_builder.rb', line 81 def text_area(method, = {}) .deep_stringify_keys! ["label"] = .fetch("label") { build_label(method, ) } ["has_error"] = has_errors_for?(method) ["helper_text"] = errors_for(method).join(", ") Tags::TextArea.new(object_name, method, self, ()).render end |
#text_field(method, options = {}) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'app/components/arara/form_builder.rb', line 62 def text_field(method, = {}) .deep_stringify_keys! ["label"] = .fetch("label") { build_label(method, ) } ["has_error"] = has_errors_for?(method) ["helper_text"] ||= errors_for(method).join(", ") Tags::TextField.new(object_name, method, self, ()).render end |