Rails passing form_for object to partial

前端 未结 3 880
情歌与酒
情歌与酒 2020-12-29 03:03

I would like to pass the form_for object to a partial:

<%= form_for @price do |f| %>
   ...
   <%= render :partial => \"price_page\"         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 03:41

    You can pass form builder object as a local variable like below,

    <%= form_for @price do |f| %>
         <%= render :partial => "price_page", :locals => { :f => f } %>
    <% end %>
    

    in your partial file you will be receiving form builder as a local variable "f", you can use like below,

      <% f.radio_button, {} %>
    

提交回复
热议问题