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
- CHECK =
What a box that is ticked wears, and what a circle does.
'check'- RADIO =
'radio'
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, which a browser offers the one it keeps.
-
#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, which a browser offers the one it keeps.
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.
A description: is the line under those words, for a box whose label is too short to
say what ticking it means. Every other option is the box's.
63 64 65 66 67 68 |
# File 'lib/bh/form_builder/controls.rb', line 63 def check(method, text, = {}) box = check_box method, .except(:description) inside = @template.safe_join [box, checked_words(method, text, [:description])] @template.tag.div inside, class: 'form-field' end |
#check_box(method, options = {}, checked = '1', unchecked = '0') ⇒ Object
One of several, ticked.
50 51 52 |
# File 'lib/bh/form_builder/controls.rb', line 50 def check_box(method, = {}, checked = '1', unchecked = '0') super(method, with_classes(, CHECK), checked, unchecked) end |
#date_field(method, options = {}) ⇒ Object
A day.
33 |
# File 'lib/bh/form_builder/controls.rb', line 33 def date_field(method, = {}) = super(method, dressed(method, )) |
#datetime_field(method, options = {}) ⇒ Object
A day and a time together.
39 |
# File 'lib/bh/form_builder/controls.rb', line 39 def datetime_field(method, = {}) = super(method, dressed(method, )) |
#email_field(method, options = {}) ⇒ Object
An email address, which a browser offers the one it keeps.
14 15 16 |
# File 'lib/bh/form_builder/controls.rb', line 14 def email_field(method, = {}) super(method, { autocomplete: 'email' }.merge(dressed(method, ))) end |
#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, dressed(method, )) |
#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, dressed(method, )) |
#radio_button(method, value, options = {}) ⇒ Object
One of several, and only one.
55 56 57 |
# File 'lib/bh/form_builder/controls.rb', line 55 def (method, value, = {}) super(method, value, with_classes(, RADIO)) 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, dressed(method, )) |
#select(method, choices = nil, options = {}, html_options = {}) ⇒ Object
A menu of what a column may be.
45 46 47 |
# File 'lib/bh/form_builder/controls.rb', line 45 def select(method, choices = nil, = {}, = {}, &) super(method, choices, , dressed(method, ), &) end |
#text_area(method, options = {}) ⇒ Object
More than a line of words.
42 |
# File 'lib/bh/form_builder/controls.rb', line 42 def text_area(method, = {}) = super(method, dressed(method, )) |
#time_field(method, options = {}) ⇒ Object
A time of day.
36 |
# File 'lib/bh/form_builder/controls.rb', line 36 def time_field(method, = {}) = super(method, dressed(method, )) |
#url_field(method, options = {}) ⇒ Object
A web address, which a browser offers the one it keeps.
28 29 30 |
# File 'lib/bh/form_builder/controls.rb', line 28 def url_field(method, = {}) super(method, { autocomplete: 'url' }.merge(dressed(method, ))) end |