Module: GenericFormFor::Inputs::Base::Label
- Included in:
- GenericFormFor::Inputs::Base
- Defined in:
- lib/generic_form_for/inputs/base/label.rb
Instance Method Summary collapse
- #label_html(config_options = {}) ⇒ Object
- #label_html_options(config_options = {}) ⇒ Object
- #label_text ⇒ Object
- #render_label? ⇒ Boolean
- #requirement_text ⇒ Object
- #translated_label ⇒ Object
Instance Method Details
#label_html(config_options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/generic_form_for/inputs/base/label.rb', line 6 def label_html(={}) return unless render_label? template.concat builder.label(method, label_text, ()) end |
#label_html_options(config_options = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/generic_form_for/inputs/base/label.rb', line 11 def (={}) opts = ([:label_html] || {}).dup opts[:for] ||= [:id] opts[:class] = [*opts[:class], *[:class]].compact.join(' ').strip .merge(opts) end |
#label_text ⇒ Object
18 19 20 |
# File 'lib/generic_form_for/inputs/base/label.rb', line 18 def label_text (translated_label << requirement_text).html_safe end |
#render_label? ⇒ Boolean
35 36 37 |
# File 'lib/generic_form_for/inputs/base/label.rb', line 35 def render_label? !([:label] == false) end |
#requirement_text ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/generic_form_for/inputs/base/label.rb', line 22 def requirement_text return "" unless required? if builder.required_string.respond_to?(:call) builder.required_string.call else builder.required_string end end |
#translated_label ⇒ Object
31 32 33 |
# File 'lib/generic_form_for/inputs/base/label.rb', line 31 def translated_label translate_label([:label] || method) end |