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
# 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'),
    (block_given? ? capture(&block) : (:button, name, options[:input]))
  ]

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

#input_html_options ⇒ Object



36
37
38
# File 'app/models/effective/form_inputs/submit.rb', line 36

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

#label_options ⇒ Object



40
41
42
# File 'app/models/effective/form_inputs/submit.rb', line 40

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_options ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/effective/form_inputs/submit.rb', line 20

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?),
    ('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