Module: ViewComponent::Form::Helpers::Rails
- Included in:
- Builder
- Defined in:
- lib/view_component/form/helpers/rails.rb
Overview
rubocop:disable Metrics/ModuleLength
Class Method Summary collapse
-
.included(base) ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Summary collapse
- #button(value = nil, options = {}) ⇒ Object
- #check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
- #collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
-
#collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#date_select(method, options = {}, html_options = {}) ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #datetime_field(method, options = {}) ⇒ Object (also: #datetime_local_field)
- #datetime_select(method, options = {}, html_options = {}) ⇒ Object
- #file_field(method, options = {}) ⇒ Object
- #grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ Object
- #label(method, text = nil, options = {}) ⇒ Object
- #radio_button(method, tag_value, options = {}) ⇒ Object
- #rich_text_area(method, options = {}) ⇒ Object
- #select(method, choices = nil, options = {}, html_options = {}) ⇒ Object
- #submit(value = nil, options = {}) ⇒ Object
-
#text_area(method, options = {}) ⇒ Object
rubocop:enable Metrics/MethodLength.
- #time_select(method, options = {}, html_options = {}) ⇒ Object
- #time_zone_select(method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
rubocop:disable Metrics/MethodLength
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/view_component/form/helpers/rails.rb', line 9 def self.included(base) base.class_eval do # rubocop:disable Metrics/BlockLength (field_helpers - i[ text_area textarea check_box checkbox datetime_field datetime_local_field fields fields_for file_field hidden_field label phone_field ]).each do |selector| class_eval " def \#{selector}(method, options = {}) # def text_field(method, options = {})\n render_component( # render_component(\n :\#{selector}, # :text_field,\n @object_name, # @object_name,\n method, # method,\n objectify_options(options), # objectify_options(options),\n ) # )\n end # end\n RUBY_EVAL\n end\n\n alias_method :phone_field, :telephone_field\n end\nend\n", __FILE__, __LINE__ + 1 |
Instance Method Details
#button(value = nil, options = {}) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/view_component/form/helpers/rails.rb', line 83 def (value = nil, = {}, &) if value.is_a?(Hash) = value value = nil end value ||= submit_default_value render_component(:button, value, , &) end |
#check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
59 60 61 |
# File 'lib/view_component/form/helpers/rails.rb', line 59 def check_box(method, = {}, checked_value = "1", unchecked_value = "0") render_component(:check_box, @object_name, method, checked_value, unchecked_value, ()) end |
#collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/view_component/form/helpers/rails.rb', line 120 def collection_check_boxes(method, collection, value_method, text_method, = {}, = {}, &) render_component( :collection_check_boxes, @object_name, method, collection, value_method, text_method, (), .merge(), & ) end |
#collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/view_component/form/helpers/rails.rb', line 128 def ( method, collection, value_method, text_method, = {}, = {}, & ) render_component( :collection_radio_buttons, @object_name, method, collection, value_method, text_method, (), .merge(), & ) end |
#collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
rubocop:disable Metrics/ParameterLists
101 102 103 104 105 106 |
# File 'lib/view_component/form/helpers/rails.rb', line 101 def collection_select(method, collection, value_method, text_method, = {}, = {}) render_component( :collection_select, @object_name, method, collection, value_method, text_method, (), .merge() ) end |
#date_select(method, options = {}, html_options = {}) ⇒ Object
rubocop:enable Metrics/ParameterLists
141 142 143 144 145 146 |
# File 'lib/view_component/form/helpers/rails.rb', line 141 def date_select(method, = {}, = {}) render_component( :date_select, @object_name, method, (), .merge() ) end |
#datetime_field(method, options = {}) ⇒ Object Also known as: datetime_local_field
52 53 54 55 56 |
# File 'lib/view_component/form/helpers/rails.rb', line 52 def datetime_field(method, = {}) render_component( :datetime_local_field, @object_name, method, () ) end |
#datetime_select(method, options = {}, html_options = {}) ⇒ Object
148 149 150 151 152 153 |
# File 'lib/view_component/form/helpers/rails.rb', line 148 def datetime_select(method, = {}, = {}) render_component( :datetime_select, @object_name, method, (), .merge() ) end |
#file_field(method, options = {}) ⇒ Object
69 70 71 72 |
# File 'lib/view_component/form/helpers/rails.rb', line 69 def file_field(method, = {}) self.multipart = true render_component(:file_field, @object_name, method, ()) end |
#grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/view_component/form/helpers/rails.rb', line 108 def grouped_collection_select( method, collection, group_method, group_label_method, option_key_method, option_value_method, = {}, = {} ) render_component( :grouped_collection_select, @object_name, method, collection, group_method, group_label_method, option_key_method, option_value_method, (), .merge() ) end |
#label(method, text = nil, options = {}) ⇒ Object
48 49 50 |
# File 'lib/view_component/form/helpers/rails.rb', line 48 def label(method, text = nil, = {}, &) render_component(:label, @object_name, method, text, (), &) end |
#radio_button(method, tag_value, options = {}) ⇒ Object
63 64 65 66 67 |
# File 'lib/view_component/form/helpers/rails.rb', line 63 def (method, tag_value, = {}) render_component( :radio_button, @object_name, method, tag_value, () ) end |
#rich_text_area(method, options = {}) ⇒ Object
170 171 172 |
# File 'lib/view_component/form/helpers/rails.rb', line 170 def rich_text_area(method, = {}) render_component(:rich_text_area, @object_name, method, ()) end |
#select(method, choices = nil, options = {}, html_options = {}) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/view_component/form/helpers/rails.rb', line 93 def select(method, choices = nil, = {}, = {}, &) render_component( :select, @object_name, method, choices, (), .merge(), & ) end |
#submit(value = nil, options = {}) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/view_component/form/helpers/rails.rb', line 74 def submit(value = nil, = {}) if value.is_a?(Hash) = value value = nil end value ||= submit_default_value render_component(:submit, value, ) end |
#text_area(method, options = {}) ⇒ Object
rubocop:enable Metrics/MethodLength
43 44 45 |
# File 'lib/view_component/form/helpers/rails.rb', line 43 def text_area(method, = {}) render_component(:text_area, @object_name, method, ()) end |
#time_select(method, options = {}, html_options = {}) ⇒ Object
155 156 157 158 159 160 |
# File 'lib/view_component/form/helpers/rails.rb', line 155 def time_select(method, = {}, = {}) render_component( :time_select, @object_name, method, (), .merge() ) end |
#time_zone_select(method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
162 163 164 165 166 167 |
# File 'lib/view_component/form/helpers/rails.rb', line 162 def time_zone_select(method, priority_zones = nil, = {}, = {}) render_component( :time_zone_select, @object_name, method, priority_zones, (), .merge() ) end |