Default Value ( another one..) but in nested fields

60 views
Skip to first unread message

erwin

unread,
Mar 21, 2012, 12:02:19 PM3/21/12
to SimpleForm
I have a simple_form , with nested attributes :
Project model
..
has_many :expenses
accepts_nested_attributes_for :expenses, :reject_if
=> :all_blank, :allow_destroy => true
attr_accessible :expenses_attributes

Expense Form view

= simple_form_for @project, :url =>
update_expenses_project_path, :method => :put, :remote => true, :html
=> {:class => ' stacked-form'} do |f|
..
= f.fields_for :expenses do |f|
.row{:id => f.object_name}
= f.input :label, :input_html => { :class =>
"span2", :value = > @project[:name] }
....
= link_to_remove_association f ...

= link_to_add_association f,

whenever I add a expense , the label value is not set ... I tried with
a string "AAA" same issue ...

Carlos Antonio da Silva

unread,
Mar 21, 2012, 12:42:29 PM3/21/12
to plataformate...@googlegroups.com
I think you're using `f` for both form and fields_for:

     f.fields_for :expenses do |f|

Also, try to use simple_fields_for instead.

-- 
At.
Carlos Antonio

erwin

unread,
Mar 21, 2012, 12:56:59 PM3/21/12
to SimpleForm
thanks I'll ... I found the issue ...
moving to the form into a modal window, I was using a duplicated (and
renamed) copy of _expense_fields.html.haml partial
and I was testing in with this copy ...

obviously the = link_to_add_association f, :expenses is using the
initial partial .... _expense_fields.html.haml
so all my tests were bypassed ...



On Mar 21, 5:42 pm, Carlos Antonio da Silva
Reply all
Reply to author
Forward
0 new messages