Class: ActionValidator::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- ActionValidator::FormBuilder
- Defined in:
- lib/action_validator/form_builder.rb
Overview
A custom FormBuilder class that renders inputs with all the necessary attributes for the ActionValidator Stimulus controller to work.
Instance Method Summary collapse
-
#check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
:nodoc:.
-
#date_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#datetime_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#datetime_local_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#email_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#error(attribute, options = {}) ⇒ Object
:nodoc:.
-
#file_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#hidden_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#month_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#number_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#password_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#phone_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#radio_button(attribute, options = {}) ⇒ Object
:nodoc:.
-
#range_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#rich_text_area(attribute, options = {}) ⇒ Object
:nodoc:.
-
#search_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
:nodoc:.
-
#submit(value = nil, options = {}, &block) ⇒ Object
:nodoc:.
-
#telephone_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#text_area(attribute, options = {}) ⇒ Object
:nodoc:.
-
#text_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#time_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#url_field(attribute, options = {}) ⇒ Object
:nodoc:.
-
#week_field(attribute, options = {}) ⇒ Object
:nodoc:.
Instance Method Details
#check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
:nodoc:
58 59 60 61 62 63 |
# File 'lib/action_validator/form_builder.rb', line 58 def check_box(attribute, = {}, checked_value = "1", unchecked_value = "0") # :nodoc: [:data] ||= {} [:data].merge!((attribute, )) super(attribute, , checked_value, unchecked_value) end |
#date_field(attribute, options = {}) ⇒ Object
:nodoc:
42 43 44 |
# File 'lib/action_validator/form_builder.rb', line 42 def date_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#datetime_field(attribute, options = {}) ⇒ Object
:nodoc:
65 66 67 |
# File 'lib/action_validator/form_builder.rb', line 65 def datetime_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#datetime_local_field(attribute, options = {}) ⇒ Object
:nodoc:
69 70 71 |
# File 'lib/action_validator/form_builder.rb', line 69 def datetime_local_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#email_field(attribute, options = {}) ⇒ Object
:nodoc:
50 51 52 |
# File 'lib/action_validator/form_builder.rb', line 50 def email_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#error(attribute, options = {}) ⇒ Object
:nodoc:
15 16 17 18 19 20 21 |
# File 'lib/action_validator/form_builder.rb', line 15 def error(attribute, = {}) # :nodoc: [:data] ||= {} [:data][ActionValidator::STIMULUS_SELECTORS[:target]] = :error [:data][:attribute] = attribute @template.tag(:div, { **, id: attribute }) end |
#file_field(attribute, options = {}) ⇒ Object
:nodoc:
73 74 75 |
# File 'lib/action_validator/form_builder.rb', line 73 def file_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#hidden_field(attribute, options = {}) ⇒ Object
:nodoc:
77 78 79 |
# File 'lib/action_validator/form_builder.rb', line 77 def hidden_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#month_field(attribute, options = {}) ⇒ Object
:nodoc:
81 82 83 |
# File 'lib/action_validator/form_builder.rb', line 81 def month_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#number_field(attribute, options = {}) ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/action_validator/form_builder.rb', line 38 def number_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#password_field(attribute, options = {}) ⇒ Object
:nodoc:
85 86 87 |
# File 'lib/action_validator/form_builder.rb', line 85 def password_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#phone_field(attribute, options = {}) ⇒ Object
:nodoc:
54 55 56 |
# File 'lib/action_validator/form_builder.rb', line 54 def phone_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#radio_button(attribute, options = {}) ⇒ Object
:nodoc:
89 90 91 |
# File 'lib/action_validator/form_builder.rb', line 89 def (attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#range_field(attribute, options = {}) ⇒ Object
:nodoc:
93 94 95 |
# File 'lib/action_validator/form_builder.rb', line 93 def range_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#rich_text_area(attribute, options = {}) ⇒ Object
:nodoc:
97 98 99 |
# File 'lib/action_validator/form_builder.rb', line 97 def rich_text_area(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#search_field(attribute, options = {}) ⇒ Object
:nodoc:
101 102 103 |
# File 'lib/action_validator/form_builder.rb', line 101 def search_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#select(method, choices = nil, options = {}, html_options = {}, &block) ⇒ Object
:nodoc:
8 9 10 11 12 13 |
# File 'lib/action_validator/form_builder.rb', line 8 def select(method, choices = nil, = {}, = {}, &block) # :nodoc: [:data] ||= {} [:data].merge!((attribute, )) super end |
#submit(value = nil, options = {}, &block) ⇒ Object
:nodoc:
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/action_validator/form_builder.rb', line 23 def submit(value = nil, = {}, &block) # :nodoc: if value.is_a?(Hash) = value value = nil end [:data] ||= {} [:data].merge!("action-validator--form-target" => :submit) super end |
#telephone_field(attribute, options = {}) ⇒ Object
:nodoc:
105 106 107 |
# File 'lib/action_validator/form_builder.rb', line 105 def telephone_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#text_area(attribute, options = {}) ⇒ Object
:nodoc:
46 47 48 |
# File 'lib/action_validator/form_builder.rb', line 46 def text_area(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#text_field(attribute, options = {}) ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/action_validator/form_builder.rb', line 34 def text_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#time_field(attribute, options = {}) ⇒ Object
:nodoc:
109 110 111 |
# File 'lib/action_validator/form_builder.rb', line 109 def time_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#url_field(attribute, options = {}) ⇒ Object
:nodoc:
113 114 115 |
# File 'lib/action_validator/form_builder.rb', line 113 def url_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |
#week_field(attribute, options = {}) ⇒ Object
:nodoc:
117 118 119 |
# File 'lib/action_validator/form_builder.rb', line 117 def week_field(attribute, = {}) # :nodoc: render_field(attribute, ) { super } end |