class Forme::Labeler::Bootstrap5

  1. lib/forme/bs5.rb
Superclass: Explicit

Methods

Public Instance

  1. call

Public Instance methods

call(tag, input)
[show source]
    # File lib/forme/bs5.rb
119 def call(tag, input)
120   floating_label = (input.opts[:wrapper_attr] || {})[:class].to_s.include?("form-floating")
121   input.opts[:label_position] ||= :after if floating_label
122 
123   tags = super
124   return tags if floating_label
125 
126   attr = tags.find { |tag| tag.is_a?(Tag) && tag.type == :label }.attr
127 
128   label_class = case input.type
129   when :radio, :checkbox
130     "form-check-label"
131   else
132     "form-label"
133   end
134   Forme.attr_classes_after(attr, label_class)
135 
136   tags
137 end