Module: Bh::FormBuilder::Controls
- Included in:
- Bh::FormBuilder
- Defined in:
- lib/bh/form_builder/controls.rb
Overview
Every other kind of field, at the one size this builder draws them: a page says which kind it wants and nothing about how it looks. Rails hands an undressed control to whatever it has no method for here, which is how a Bootstrap class ends up written in a view.
Constant Summary collapse
- MENU =
What a menu wears: the control's size, so a menu and a box beside it line up.
'form-select form-select-lg'- CHECK =
What a box or a circle that is ticked wears.
'form-check-input'
Instance Method Summary collapse
-
#check(method, text, options = {}) ⇒ Object
A box and the words beside it, which is the one place words sit after a control rather than over it -- so they are not the label a field wears, and are written here instead.
-
#check_box(method, options = {}, checked = '1', unchecked = '0') ⇒ Object
One of several, ticked.
-
#date_field(method, options = {}) ⇒ Object
A day.
-
#datetime_field(method, options = {}) ⇒ Object
A day and a time together.
-
#email_field(method, options = {}) ⇒ Object
An email address.
-
#number_field(method, options = {}) ⇒ Object
A number, which brings the keyboard for one.
-
#password_field(method, options = {}) ⇒ Object
A password, which no name of a column earns on its own.
-
#radio_button(method, value, options = {}) ⇒ Object
One of several, and only one.
-
#search_field(method, options = {}) ⇒ Object
A term to search by.
-
#select(method, choices = nil, options = {}, html_options = {}) ⇒ Object
A menu of what a column may be.
-
#text_area(method, options = {}) ⇒ Object
More than a line of words.
-
#time_field(method, options = {}) ⇒ Object
A time of day.
-
#url_field(method, options = {}) ⇒ Object
A web address.
Instance Method Details
#check(method, text, options = {}) ⇒ Object
A box and the words beside it, which is the one place words sit after a control rather than over it -- so they are not the label a field wears, and are written here instead.
59 60 61 62 63 64 |
# File 'lib/bh/form_builder/controls.rb', line 59 def check(method, text, = {}) words = @template.label_tag field_id(method), text, class: 'form-check-label' inside = @template.safe_join [check_box(method, ), words] @template.tag.div inside, class: 'form-check' end |
#check_box(method, options = {}, checked = '1', unchecked = '0') ⇒ Object
One of several, ticked.
48 49 50 |
# File 'lib/bh/form_builder/controls.rb', line 48 def check_box(method, = {}, checked = '1', unchecked = '0') super(method, with_classes(, CHECK), checked, unchecked) end |
#date_field(method, options = {}) ⇒ Object
A day.
31 |
# File 'lib/bh/form_builder/controls.rb', line 31 def date_field(method, = {}) = super(method, with_classes(, CONTROL)) |
#datetime_field(method, options = {}) ⇒ Object
A day and a time together.
37 |
# File 'lib/bh/form_builder/controls.rb', line 37 def datetime_field(method, = {}) = super(method, with_classes(, CONTROL)) |
#email_field(method, options = {}) ⇒ Object
An email address.
16 |
# File 'lib/bh/form_builder/controls.rb', line 16 def email_field(method, = {}) = super(method, with_classes(, CONTROL)) |
#number_field(method, options = {}) ⇒ Object
A number, which brings the keyboard for one.
19 |
# File 'lib/bh/form_builder/controls.rb', line 19 def number_field(method, = {}) = super(method, with_classes(, CONTROL)) |
#password_field(method, options = {}) ⇒ Object
A password, which no name of a column earns on its own.
22 |
# File 'lib/bh/form_builder/controls.rb', line 22 def password_field(method, = {}) = super(method, with_classes(, CONTROL)) |
#radio_button(method, value, options = {}) ⇒ Object
One of several, and only one.
53 54 55 |
# File 'lib/bh/form_builder/controls.rb', line 53 def (method, value, = {}) super(method, value, with_classes(, CHECK)) end |
#search_field(method, options = {}) ⇒ Object
A term to search by.
25 |
# File 'lib/bh/form_builder/controls.rb', line 25 def search_field(method, = {}) = super(method, with_classes(, CONTROL)) |
#select(method, choices = nil, options = {}, html_options = {}) ⇒ Object
A menu of what a column may be.
43 44 45 |
# File 'lib/bh/form_builder/controls.rb', line 43 def select(method, choices = nil, = {}, = {}, &) super(method, choices, , with_classes(, MENU), &) end |
#text_area(method, options = {}) ⇒ Object
More than a line of words.
40 |
# File 'lib/bh/form_builder/controls.rb', line 40 def text_area(method, = {}) = super(method, with_classes(, CONTROL)) |
#time_field(method, options = {}) ⇒ Object
A time of day.
34 |
# File 'lib/bh/form_builder/controls.rb', line 34 def time_field(method, = {}) = super(method, with_classes(, CONTROL)) |
#url_field(method, options = {}) ⇒ Object
A web address.
28 |
# File 'lib/bh/form_builder/controls.rb', line 28 def url_field(method, = {}) = super(method, with_classes(, CONTROL)) |