module Form module Component class Label < Base def attributes options.except(:text).tap do |attrs| attrs[:for] ||= id_attribute end end def text scopes = [ [:form, :labels, form.base_name, name].flatten.compact.join(".").to_sym, :"form.labels.#{name}", humanize(name) ].compact options.fetch :text, t(scopes.shift, default: scopes) end def to_html Tag.new(:label, text, attributes).to_s end end end end