Module: FormtasticRebootstrap::Inputs::Base::Html

Includes:
Formtastic::Inputs::Base::Html
Included in:
FormtasticRebootstrap::Inputs::Base
Defined in:
lib/formtastic_rebootstrap/inputs/base/html.rb

Instance Method Summary collapse

Instance Method Details

#form_control_input_html_optionsObject



8
9
10
11
# File 'lib/formtastic_rebootstrap/inputs/base/html.rb', line 8

def form_control_input_html_options
  new_classes = input_class_without_col&.compact&.join(" ")
  input_html_options.merge(:class => new_classes)
end

#input_class_without_colObject



17
18
19
20
21
# File 'lib/formtastic_rebootstrap/inputs/base/html.rb', line 17

def input_class_without_col
  ['form-control'] <<  original_classes&.reject do |c|
    c.match(/^col-(sm|md|lg|xl)?-?[0-9]{1,2}/)
  end&.join(' ')
end

#input_html_optionsObject



23
24
25
26
27
28
29
30
31
# File 'lib/formtastic_rebootstrap/inputs/base/html.rb', line 23

def input_html_options
  if errors?
    {
      :class => "error"
    }.merge(super)
  else
    super
  end
end

#original_classesObject



13
14
15
# File 'lib/formtastic_rebootstrap/inputs/base/html.rb', line 13

def original_classes
  input_html_options[:class]&.split(' ')&.flatten
end