Module: Decidim::ReplaceButtonsHelper

Included in:
ViewModel
Defined in:
decidim-core/app/helpers/decidim/replace_buttons_helper.rb

Instance Method Summary collapse

Instance Method Details

#button_to(*arguments, &block) ⇒ Object

Public: Overrides button_to so it always renders buttons instead of input tags.

arguments - The same arguments that would be sent to `button_to`. block - An optional block to be sent.

Returns a button.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'decidim-core/app/helpers/decidim/replace_buttons_helper.rb', line 25

def button_to(*arguments, &block)
  if block_given?
    body = block
    url = arguments[0]
    html_options = arguments[1] || {}
  else
    body = arguments[0]
    url = arguments[1]
    html_options = arguments[2] || {}
  end

  if block_given?
    super(url, html_options, &body)
  else
    super(url, html_options) { body }
  end
end

#submit_tag(text = "Save changes", options = {}) ⇒ Object

Overrides the submit tags to always be buttons instead of inputs. Buttons are much more stylable and less prone to bugs.

value - The text of the button options - Options to provide to the actual tag.

Returns a SafeString with the tag.


12
13
14
15
16
# File 'decidim-core/app/helpers/decidim/replace_buttons_helper.rb', line 12

def submit_tag(text = "Save changes", options = {})
  options = options.stringify_keys

   :button, text, { "type" => "submit", "name" => "commit" }.update(options)
end