2014-10-27 83 views
0

我有经由Cocoon gem使用嵌套字段一个滑轨应用程序:抓斗表单数据嵌套字段

_form.html.haml:

= form_for @project do |f| 
    %h3 Tasks 
    #tasks 
     = f.fields_for :tasks do |task| 
      = render 'task_fields', :f => task 
     .links 
      = link_to_add_association 'add task', f, :tasks 
    = f.submit 

_task_fields.html.haml:

.nested-fields 
    .field 
     = f.label :description 
     %br 
     = f.text_field :description 
     **********HERE's WHERE I WANT TO ECHO OUT THE DESCRIPTION FOR THIS PARTICULAR TASK** 
    .field 
     = f.check_box :done 
     = f.label :done 
    = link_to_remove_association "remove task", f 

我需要做的是在编辑页面为用户检索每个任务描述值。

+0

你是什么意思*上检索每个任务的描述值用户的编辑页面*?你不在这里有任务吗? '= f.text_field:description'? – Surya 2014-10-27 06:49:54

+0

@ User089247,我想再次回显描述,而不是在标签或文本字段中。我只想要领域的价值。 – Muhambi 2014-10-27 16:03:32

+0

回声是什么意思?你想要描述显示在页面上?或者它应该在日志中默默显示? – Surya 2014-10-27 18:13:01

回答

1

不知道你的回音是什么意思,但要获得任务的description_task_fields.html.haml,你可以这样做:

.nested-fields 
    .field 
     = f.label :description 
     %br 
     = f.text_field :description 
     = f.object.description # will show description if exists on form's object here. 
    .field 
     = f.check_box :done 
     = f.label :done 
    = link_to_remove_association "remove task", f