Module: Formtastic::Inputs::Base::Labelling
- Includes:
- LocalizedString
- Included in:
- Formtastic::Inputs::Base
- Defined in:
- lib/formtastic/inputs/base/labelling.rb
Instance Method Summary collapse
- #label_from_options ⇒ Object
- #label_html ⇒ Object
- #label_html_options ⇒ Object
- #label_text ⇒ Object
- #localized_label ⇒ Object
- #render_label? ⇒ Boolean
- #requirement_text ⇒ Object
-
#requirement_text_or_proc ⇒ Object
TODO: why does this need to be memoized in order to make the inputs_spec tests pass?.
Methods included from LocalizedString
Instance Method Details
#label_from_options ⇒ Object
39 40 41 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 39 def [:label] end |
#label_html ⇒ Object
8 9 10 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 8 def label_html render_label? ? builder.label(input_name, label_text, ) : "".html_safe end |
#label_html_options ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 12 def # opts = options_for_label(options) # TODO opts = {} opts[:for] ||= [:id] opts[:class] = [opts[:class]] opts[:class] << 'label' opts end |
#label_text ⇒ Object
22 23 24 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 22 def label_text ((localized_label || humanized_method_name) + requirement_text).html_safe end |
#localized_label ⇒ Object
43 44 45 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 43 def localized_label localized_string(method, || method, :label) end |
#render_label? ⇒ Boolean
47 48 49 50 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 47 def render_label? return false if [:label] == false true end |
#requirement_text ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 31 def requirement_text if requirement_text_or_proc.respond_to?(:call) requirement_text_or_proc.call else requirement_text_or_proc end end |
#requirement_text_or_proc ⇒ Object
TODO: why does this need to be memoized in order to make the inputs_spec tests pass?
27 28 29 |
# File 'lib/formtastic/inputs/base/labelling.rb', line 27 def requirement_text_or_proc @requirement_text_or_proc ||= required? ? builder.required_string : builder.optional_string end |