Sha256: 39abfdea44c76943e2519a32bc9cc81374e958f07181313f0e697c296777e1a7
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module SimpleFormWithClientValidation 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 || SimpleFormWithClientValidation::Wrappers::Many.new(name, [name]) end private def html_classes(input, options) css = options[:wrapper_class] ? Array.wrap(options[:wrapper_class]) : @defaults[:class] css += SimpleFormWithClientValidation.additional_classes_for(:wrapper) { input.html_classes } 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 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems