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::DEFAULT_FEEDBACK_OPTIONS, Effective::FormInput::DEFAULT_INPUT_GROUP_OPTIONS, Effective::FormInput::EMPTY_HASH, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES, Effective::FormInput::HORIZONTAL_LABEL_OPTIONS, Effective::FormInput::HORIZONTAL_WRAPPER_OPTIONS, Effective::FormInput::INLINE_LABEL_OPTIONS, Effective::FormInput::VERTICAL_WRAPPER_OPTIONS

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



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

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



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

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

#label_optionsObject



52
53
54
# File 'app/models/effective/form_inputs/submit.rb', line 52

def label_options
  false
end

#to_html(&block) ⇒ Object



7
8
9
10
# File 'app/models/effective/form_inputs/submit.rb', line 7

def to_html(&block)
  return nil if form_readonly?
  super()
end

#wrapper_optionsObject



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

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