Class: Effective::FormInputs::Submit

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

Direct Known Subclasses

Delete, RemoteLinkTo

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

Constructor Details

This class inherits a constructor from Effective::FormInput

Instance Method Details

#build_input(&block) ⇒ Object



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 build_input(&block)
  tags = [
    icon('check', style: 'display: none;'),
    icon('x', style: 'display: none;'),
    icon('spinner'),
    (
      if block_given?
        capture(&block)
      else
        (:button, options[:input]) do
          icon_name.present? ? (icon(icon_name) + name) : name
        end
      end
    )
  ]

  (left? ? tags.reverse.join : tags.join).html_safe
end

#input_html_optionsObject



45
46
47
# File 'app/models/effective/form_inputs/submit.rb', line 45

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

#label_optionsObject



49
50
51
# File 'app/models/effective/form_inputs/submit.rb', line 49

def label_options
  false
end

#to_html(&block) ⇒ Object



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

def to_html(&block)
  return super unless (form_readonly? || form_disabled?)
end

#wrapper_optionsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/effective/form_inputs/submit.rb', line 28

def wrapper_options
  @right = true unless (left? || center? || right?)

  classes = [
    ('row' if layout == :horizontal),
    'form-group form-actions',
    ('form-actions-inline' if inline?),
    ('form-actions-bordered' if border?),
    ('form-actions-reset' if reset?),
    ('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, id: tag_id }
end