Created
April 30, 2012 03:21
-
-
Save ncherro/2555189 to your computer and use it in GitHub Desktop.
Nested Form monkeypatch - add / remove buttons with twitter bootstrap classes
This file contains 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
require 'nested_form/builder_mixin' | |
module NestedForm | |
module BuilderMixin | |
alias_method :link_to_add_original, :link_to_add | |
alias_method :link_to_remove_original, :link_to_remove | |
def link_to_add(*args, &block) | |
options = args.extract_options!.symbolize_keys | |
options[:class] = [options[:class], 'btn btn-inverse'].compact.join(' ') unless options[:plain] | |
link_to_add_original *args, options, &block | |
end | |
def link_to_remove(*args, &block) | |
options = args.extract_options!.symbolize_keys | |
options[:class] = [options[:class], 'btn btn-danger'].compact.join(' ') unless options[:plain] | |
link_to_remove_original "<i class=\"icon-trash icon-white\"></i> #{args.first}".html_safe, options, &block | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment