From 7e8de741761a206f4403b0097e9d1421ae954285 Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Fri, 4 Mar 2011 16:36:12 +0100 Subject: [PATCH] Use hidden_field_tag instead of hidden_field. This works around problems with accepts_nested_attributes_for :reject_if => :all_blank. hidden_field injects a (String!) value of "false" into the form, effectively disabling the all_blank check. --- lib/cocoon/view_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cocoon/view_helpers.rb b/lib/cocoon/view_helpers.rb index 459f45b..213edeb 100644 --- a/lib/cocoon/view_helpers.rb +++ b/lib/cocoon/view_helpers.rb @@ -26,7 +26,7 @@ module Cocoon is_dynamic = f.object.new_record? html_options[:class] = [html_options[:class], "remove_fields #{is_dynamic ? 'dynamic' : 'existing'}"].compact.join(' ') - f.hidden_field(:_destroy) + link_to(name, '#', html_options) + hidden_field_tag("#{f.object_name}[_destroy]") + link_to(name, '#', html_options) end end