Module: ButtonToFormHelper
- Defined in:
- app/helpers/button_to_form_helper.rb
Class Attribute Summary collapse
-
.content_for_name ⇒ Object
Returns the value of attribute content_for_name.
Instance Method Summary collapse
-
#button_to_form(button_text, url, button_options = {}, form_options = {}, &block) ⇒ Object
The button_to provided by rails doesn't work when used inside of a form tag, because it adds a new
Class Attribute Details
.content_for_name ⇒ Object
Returns the value of attribute content_for_name.
3 4 5 |
# File 'app/helpers/button_to_form_helper.rb', line 3 def content_for_name @content_for_name end |
Instance Method Details
#button_to_form(button_text, url, button_options = {}, form_options = {}, &block) ⇒ Object
The button_to provided by rails doesn't work when used inside of a form tag, because it adds a new
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/helpers/button_to_form_helper.rb', line 49 def (, url, = {}, = {}, &block) [:id] ||= "form-#{SecureRandom.uuid}" @button_to_form_ids ||= [] @button_to_form_id = [:id] unless @button_to_form_ids.include?(@button_to_form_id) content_for(ButtonToFormHelper.content_for_name) do form_tag(url, **) do block.call if block end end end @button_to_form_ids << @button_to_form_id (, **, type: 'submit', form: @button_to_form_id) end |