Sha256: a9c564a79433b28f4f1ce3de3d9a95c1a9a35e732276d1e612f773088defb50f

Contents?: true

Size: 932 Bytes

Versions: 43

Compression:

Stored size: 932 Bytes

Contents

module Releaf::Builders::FormBuilder::Label
  def releaf_label(name, attributes, options = {})
    label_options = options.fetch(:label, {})
    attributes = label_attributes(name, attributes, options)
    text = label_text(name, label_options)

    content = label(name, text, attributes)

    if label_options.fetch(:minimal, false) == true
      content
    else
      content += wrapper(label_options[:description], class: "description") if label_options.fetch(:description, nil).present?
      wrapper(content, class: "label-wrap")
    end
  end

  def label_text(name, options = {})
    if options[:label_text].present?
      options[:label_text]
    else
      if options[:translation_key].present?
        key = options[:translation_key]
      else
        key = name.to_s.sub(/_uid$/, '')
      end

      translate_attribute(key)
    end
  end

  def label_attributes(_name, attributes, _options)
    attributes
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
releaf-core-3.1.0 app/builders/releaf/builders/form_builder/label.rb
releaf-core-3.0.3 app/builders/releaf/builders/form_builder/label.rb
releaf-core-3.0.2 app/builders/releaf/builders/form_builder/label.rb
releaf-core-3.0.1 app/builders/releaf/builders/form_builder/label.rb
releaf-core-3.0.0 app/builders/releaf/builders/form_builder/label.rb
releaf-core-2.2.1 app/builders/releaf/builders/form_builder/label.rb
releaf-core-2.2.0 app/builders/releaf/builders/form_builder/label.rb
releaf-core-2.1.2 app/builders/releaf/builders/form_builder/label.rb
releaf-core-2.1.1 app/builders/releaf/builders/form_builder/label.rb
releaf-core-2.1.0 app/builders/releaf/builders/form_builder/label.rb
releaf-core-2.0.1 app/builders/releaf/builders/form_builder/label.rb
releaf-core-2.0.0 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.22 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.21 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.20 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.19 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.18 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.17 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.16 app/builders/releaf/builders/form_builder/label.rb
releaf-core-1.1.15 app/builders/releaf/builders/form_builder/label.rb