Module: SimpleForm::Components::Labels
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/simple_form/components/labels.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #label(wrapper_options = nil) ⇒ Object
- #label_html_options ⇒ Object
- #label_target ⇒ Object
- #label_text(wrapper_options = nil) ⇒ Object
Instance Method Details
#label(wrapper_options = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/simple_form/components/labels.rb', line 31 def label( = nil) = (, ) if generate_label_for_attribute? @builder.label(label_target, label_text, ) else template.label_tag(nil, label_text, ) end end |
#label_html_options ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/simple_form/components/labels.rb', line 50 def label_html_classes = SimpleForm.additional_classes_for(:label) { [input_type, required_class, disabled_class, SimpleForm.label_class].compact } = (:label, label_html_classes) if .key?(:input_html) && [:input_html].key?(:id) [:for] = [:input_html][:id] end end |
#label_target ⇒ Object
46 47 48 |
# File 'lib/simple_form/components/labels.rb', line 46 def label_target attribute_name end |
#label_text(wrapper_options = nil) ⇒ Object
41 42 43 44 |
# File 'lib/simple_form/components/labels.rb', line 41 def label_text( = nil) label_text = [:label_text] || SimpleForm.label_text label_text.call(html_escape(raw_label_text), required_label_text, [:label].present?).strip.html_safe end |