Module: BootstrapConcerns::FormBuilder
- Defined in:
- lib/bootstrap_concerns/form_builder.rb
Constant Summary collapse
- FORM_LABEL_BASE_CLASS =
"form-label".freeze
- FORM_CHECK_INPUT_BASE_CLASS =
"form-check-input".freeze
- FORM_CONTROL_BASE_CLASS =
"form-control".freeze
- FORM_CONTROL_PLAIN_TEXT_BASE_CLASS =
"form-control-plaintext".freeze
- FORM_SELECT_BASE_CLASS =
"form-select".freeze
- REQUIRED_CLASS =
"required".freeze
Instance Method Summary collapse
- #bs_button(value = nil, options = {}) ⇒ Object
- #bs_check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #bs_check_label(method, text = nil, options = {}) ⇒ Object
- #bs_collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
- #bs_color_field(method, options = {}) ⇒ Object
- #bs_date_field(method, options = {}) ⇒ Object
- #bs_datetime_field(method, options = {}) ⇒ Object
- #bs_email_field(method, options = {}) ⇒ Object
- #bs_grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ Object
- #bs_label(method, text = nil, options = {}) ⇒ Object
- #bs_number_field(method, options = {}) ⇒ Object
- #bs_password_field(method, options = {}) ⇒ Object
- #bs_phone_field(method, options = {}) ⇒ Object
- #bs_plain_text_field(method, options = {}) ⇒ Object
- #bs_radio_button(method, tag_value, options = {}) ⇒ Object
- #bs_search_field(method, options = {}) ⇒ Object
- #bs_select(method, choices = nil, options = {}, html_options = {}) ⇒ Object
- #bs_submit(value = nil, options = {}) ⇒ Object
- #bs_text_area(method, options = {}) ⇒ Object
- #bs_text_field(method, options = {}) ⇒ Object
- #bs_url_field(method, options = {}) ⇒ Object
Instance Method Details
#bs_button(value = nil, options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 10 def (value = nil, = {}, &) = value.is_a?(Hash) ? value : .merge!(Option.()) (value, , &) end |
#bs_check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
17 18 19 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 17 def bs_check_box(method, = {}, checked_value = "1", unchecked_value = "0") check_box(method, (), checked_value, unchecked_value) end |
#bs_check_label(method, text = nil, options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 21 def bs_check_label(method, text = nil, = {}, &) = text.is_a?(Hash) ? text : .merge!(()) label(method, text, , &) end |
#bs_collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 32 def bs_collection_select(method, collection, value_method, text_method, = {}, = {}) collection_select( method, collection, value_method, text_method, , (, ) ) end |
#bs_color_field(method, options = {}) ⇒ Object
28 29 30 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 28 def bs_color_field(method, = {}) color_field(method, ()) end |
#bs_date_field(method, options = {}) ⇒ Object
43 44 45 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 43 def bs_date_field(method, = {}) date_field(method, ()) end |
#bs_datetime_field(method, options = {}) ⇒ Object
47 48 49 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 47 def bs_datetime_field(method, = {}) datetime_field(method, ()) end |
#bs_email_field(method, options = {}) ⇒ Object
51 52 53 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 51 def bs_email_field(method, = {}) email_field(method, ()) end |
#bs_grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 55 def bs_grouped_collection_select( method, collection, group_method, group_label_method, option_key_method, option_value_method, = {}, = {} ) grouped_collection_select( method, collection, group_method, group_label_method, option_key_method, option_value_method, , (, ) ) end |
#bs_label(method, text = nil, options = {}) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 77 def bs_label(method, text = nil, = {}, &) = text.is_a?(Hash) ? text : .merge!(()) label(method, text, , &) end |
#bs_number_field(method, options = {}) ⇒ Object
84 85 86 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 84 def bs_number_field(method, = {}) number_field(method, ()) end |
#bs_password_field(method, options = {}) ⇒ Object
88 89 90 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 88 def bs_password_field(method, = {}) password_field(method, ()) end |
#bs_phone_field(method, options = {}) ⇒ Object
111 112 113 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 111 def bs_phone_field(method, = {}) phone_field(method, ()) end |
#bs_plain_text_field(method, options = {}) ⇒ Object
115 116 117 118 119 120 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 115 def bs_plain_text_field(method, = {}) text_field( method, Option.(, FORM_CONTROL_PLAIN_TEXT_BASE_CLASS).merge(readonly: true) ) end |
#bs_radio_button(method, tag_value, options = {}) ⇒ Object
92 93 94 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 92 def (method, tag_value, = {}) (method, tag_value, ()) end |
#bs_search_field(method, options = {}) ⇒ Object
96 97 98 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 96 def bs_search_field(method, = {}) search_field(method, ()) end |
#bs_select(method, choices = nil, options = {}, html_options = {}) ⇒ Object
100 101 102 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 100 def bs_select(method, choices = nil, = {}, = {}, &) select(method, choices, , (, ), &) end |
#bs_submit(value = nil, options = {}) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 104 def bs_submit(value = nil, = {}) = value.is_a?(Hash) ? value : .merge!(Option.()) submit(value, ) end |
#bs_text_area(method, options = {}) ⇒ Object
126 127 128 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 126 def bs_text_area(method, = {}) text_area(method, ()) end |
#bs_text_field(method, options = {}) ⇒ Object
122 123 124 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 122 def bs_text_field(method, = {}) text_field(method, ()) end |
#bs_url_field(method, options = {}) ⇒ Object
130 131 132 |
# File 'lib/bootstrap_concerns/form_builder.rb', line 130 def bs_url_field(method, = {}) url_field(method, ()) end |