我正在尝试将这些本地参数传递给部分表单,并将它们传递给 hidden_fields。我不能将值直接放入表格中,因为它们会改变。任何帮助将不胜感激。
我有:
<% form_for :user, @user, :url => { :action => "create", :controller => "users"} do |f| %>
<%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f, :position => 'Company Commander', :battalion_id => @battalion.id, :company_id => c.id} %>
<%= f.submit "Register" %>
<% end %>
_form.html
<%= f.hidden_field (:position, :value => :position) %>
<%= f.hidden_field (:battalion_id, :value => @battalion.id) %>
<%= f.hidden_field (:battalion_id, :value => @company.id) %>
<%= f.hidden_field (:roles, :value => "Company") %>
<%= f.label (:name, "Name:") %>
<%= f.text_field :name%>
<br />
<%= f.label (:login, "Login:") %>
<%= f.text_field :login %>
<br />
<%= f.label (:email, "E-Mail:") %>
<%= f.text_field :email%>