Sha256: 2ab5b814bd77c6830906303734b6f0d6d4424c350cfd4fdd7ae5521d5f66b5e3
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module SimpleForm module Wrappers # `Root` is the root wrapper for all components. It is special cased to # always have a namespace and to add special html classes. class Root < Many attr_reader :options def initialize(*args) super(:wrapper, *args) @options = @defaults.except(:tag, :class, :error_class, :hint_class) end def render(input) input.options.reverse_merge!(@options) super end # Provide a fallback if name cannot be found. def find(name) super || SimpleForm::Wrappers::Many.new(name, [Leaf.new(name)]) end private def html_classes(input, options) css = options[:wrapper_class] ? Array(options[:wrapper_class]) : @defaults[:class] css += SimpleForm.additional_classes_for(:wrapper) do input.additional_classes + [input.input_class] end css << (options[:wrapper_error_class] || @defaults[:error_class]) if input.has_errors? css << (options[:wrapper_hint_class] || @defaults[:hint_class]) if input.has_hint? css << (options[:wrapper_valid_class] || @defaults[:valid_class]) if input.valid? css.compact end end end end
Version data entries
5 entries across 5 versions & 1 rubygems