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

Showing 1-3 of 3 messages
Default Value ( another one..) but in nested fields Yves Dufour 3/21/12 9:02 AM
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 ...
Re: Default Value ( another one..) but in nested fields Carlos Antonio da Silva 3/21/12 9:42 AM
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

Re: Default Value ( another one..) but in nested fields Yves Dufour 3/21/12 9:56 AM
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