Class: Effective::FormInputs::Submit

Inherits:
Effective::FormInput show all
Defined in:
app/models/effective/form_inputs/submit.rb

Constant Summary

Constants inherited from Effective::FormInput

Effective::FormInput::BLANK, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES

Instance Attribute Summary

Attributes inherited from Effective::FormInput

#name, #options

Instance Method Summary collapse

Methods inherited from Effective::FormInput

#hint_options, #initialize, #input_group_options, #input_js_options, #to_html

Constructor Details

This class inherits a constructor from Effective::FormInput

Instance Method Details

#build_input(&block) ⇒ Object



5
6
7
# File 'app/models/effective/form_inputs/submit.rb', line 5

def build_input(&block)
  icon('spinner') + (block_given? ? capture(&block) : (:button, name, options[:input]))
end

#feedback_optionsObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/effective/form_inputs/submit.rb', line 36

def feedback_options
  # case layout
  # when :inline
  #   false
  # else
  #   {
  #     valid: { class: 'valid-feedback', text: 'Looks good! Submitting...' },
  #     invalid: {
  #       class: 'invalid-feedback',
  #       text: 'one or more errors are present. please fix the errors above and try again.'
  #     }
  #   }
  # end
  false
end

#input_html_optionsObject



28
29
30
# File 'app/models/effective/form_inputs/submit.rb', line 28

def input_html_options
  { class: 'btn btn-primary', type: 'submit', name: 'commit', value: name }
end

#label_optionsObject



32
33
34
# File 'app/models/effective/form_inputs/submit.rb', line 32

def label_options
  false
end

#wrapper_optionsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/effective/form_inputs/submit.rb', line 9

def wrapper_options
  border = options.key?(:border) ? options.delete(:border) : true
  left = options.delete(:left) || false
  center = options.delete(:center) || false
  right = options.delete(:right) || false
  right = true unless (left || center)

  classes = [
    ('row' if layout == :horizontal),
    'form-group form-actions',
    ('form-actions-bordered' if border),
    ('justify-content-start' if left && layout == :vertical),
    ('justify-content-center' if center && layout == :vertical),
    ('justify-content-end' if right && layout == :vertical)
  ].compact.join(' ')

  { class: classes }
end