Created
November 21, 2010 23:44
-
-
Save carlosantoniodasilva/709301 to your computer and use it in GitHub Desktop.
SimpleForm submit with cancel link example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SimpleForm | |
class FormBuilder < ActionView::Helpers::FormBuilder | |
# You can just override the default submit button and add the functionality. | |
# | |
# Simple usage: | |
# f.button :submit 'Send!', :cancel_link => root_path | |
# | |
def submit(*args) | |
cancel_link = args.last.is_a?(Hash) && args.last.delete(:cancel_link) | |
submit_button = super | |
submit_button << @template.link_to('cancel', cancel_link) if cancel_link | |
submit_button | |
end | |
# Or you can just create your own helpers to handle that. | |
# | |
def submit_with_cancel(*args) | |
# Do whatever you want here... | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment