def link_to_remove_association(*args, &block)
if block_given?
link_to_remove_association(capture(&block), *args)
elsif args.first.respond_to?(:object)
form = args.first
association = form.object.class.to_s.tableize
name = I18n.translate("cocoon.#{association}.remove", default: I18n.translate('cocoon.defaults.remove'))
link_to_remove_association(name, *args)
else
name, f, html_options = *args
html_options ||= {}
is_dynamic = f.object.new_record?
classes = []
classes << "remove_fields"
classes << (is_dynamic ? 'dynamic' : 'existing')
classes << 'destroyed' if f.object.marked_for_destruction?
html_options[:class] = [html_options[:class], classes.join(' ')].compact.join(' ')
wrapper_class = html_options.delete(:wrapper_class)
html_options['data-wrapper-class''data-wrapper-class'] = wrapper_class if wrapper_class.present?
hidden_field_tag("#{f.object_name}[_destroy]", f.object._destroy) + link_to(name, '#', html_options)
end
end