开发者

Nested model forms; How to access the parent/root FormBuilder?

开发者 https://www.devze.com 2023-02-07 23:29 出处:网络
I have the following rails erb code: <% form_for @foo do |c| %> <% c.fields_for :bars do |builder| %>

I have the following rails erb code:

<% form_for @foo do |c| %>
  <% c.fields_for :bars do |builder| %>
  <%= render 'foo/bar_fields', :f => builder %>
  <% end %>
<% end %>

Inside the _bar_fields.erb partial I can access the FormBuilder of the nested model through the 'f' instance variable. Is there a way to access the 'parent'/'root' FormBuilder through that instance variable? Or is passing another local to the partial the only way开发者_StackOverflow?


As far as I know you'd have to pass it through as another local.

0

精彩评论

暂无评论...
验证码 换一张
取 消