Module: Decidim::ReplaceButtonsHelper
- Included in:
- ViewModel
- Defined in:
- app/helpers/decidim/replace_buttons_helper.rb
Instance Method Summary collapse
-
#button_to(*arguments, &block) ⇒ Object
Public: Overrides button_to so it always renders buttons instead of input tags.
-
#submit_tag(text = "Save changes", options = {}) ⇒ Object
Overrides the submit tags to always be buttons instead of inputs.
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 'app/helpers/decidim/replace_buttons_helper.rb', line 25 def (*arguments, &block) if block_given? body = block url = arguments[0] = arguments[1] || {} else body = arguments[0] url = arguments[1] = arguments[2] || {} end if block_given? super(url, , &body) else super(url, ) { 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 'app/helpers/decidim/replace_buttons_helper.rb', line 12 def submit_tag(text = "Save changes", = {}) = .stringify_keys content_tag :button, text, { "type" => "submit", "name" => "commit" }.update() end |