Module: Para::SimpleFormConfig

Defined in:
lib/para/simple_form_config.rb

Class Method Summary collapse

Class Method Details

.configureObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/para/simple_form_config.rb', line 16

def self.configure
  # Use this setup block to configure all options available in SimpleForm.
  SimpleForm.setup do |config|
    config.error_notification_class = 'alert alert-danger'
    config.button_class = 'btn'
    config.boolean_label_class = nil

    config.wrappers :para_vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
      b.use :html5
      b.use :placeholder
      b.optional :maxlength
      b.optional :minlength
      b.optional :pattern
      b.optional :min_max
      b.optional :readonly
      b.use :label, class: 'control-label'

      b.use :input, class: 'form-control'
      b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
      b.use :hint,  wrap_with: { tag: 'p', class: 'help-block' }
    end

    config.wrappers :para_vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
      b.use :html5
      b.use :placeholder
      b.optional :maxlength
      b.optional :minlength
      b.optional :readonly
      b.use :label, class: 'control-label'

      b.use :input
      b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
      b.use :hint,  wrap_with: { tag: 'p', class: 'help-block' }
    end

    config.wrappers :para_vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
      b.use :html5
      b.optional :readonly

      b.wrapper tag: 'div', class: 'checkbox' do |ba|
        ba.use :label_input
      end

      b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
      b.use :hint,  wrap_with: { tag: 'p', class: 'help-block' }
    end

    config.wrappers :para_vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
      b.use :html5
      b.optional :readonly
      b.use :label, class: 'control-label'
      b.use :input
      b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
      b.use :hint,  wrap_with: { tag: 'p', class: 'help-block' }
    end

    config.wrappers :para_multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
      b.use :html5
      b.optional :readonly
      b.use :label, class: 'control-label'
      b.wrapper tag: 'div', class: 'form-inline' do |ba|
        ba.use :input, class: 'form-control'
        ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
        ba.use :hint,  wrap_with: { tag: 'p', class: 'help-block' }
      end
    end
  end
end

.wrapper_mappingsObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/para/simple_form_config.rb', line 4

def self.wrapper_mappings
  {
    check_boxes: :para_vertical_radio_and_checkboxes,
    radio_buttons: :para_vertical_radio_and_checkboxes,
    boolean: :para_vertical_radio_and_checkboxes,
    datetime: :para_multi_select,
    date: :para_multi_select,
    time: :para_multi_select,
    file: :para_vertical_file_input
  }
end