3

In my controller I want to receive some params like

params[:test][:test_page]

This code is in edit page like

<%= test.title%>

I can not give this in collection or any other field because I am not allowing user to edit this its showing something like fixed

so how can I pass this to controller I have a general idea about one code so giving it as reference

<%= collection_select(:test,:test_page, @testplantemplates, :id, :title,:selected => @test_plan_template_id) %>

How can we do this? I was trying hidden_field but its allow only 2 arguments. Can you give me some example or idea?

some of my code is

<% if @secu.test_plan  %>
  <%= @secu.test_plan.title %>
<% else %>
    <%= collection_select(:test_plan,:test_plan_template_id, @testplantemplates, :id, :title, :prompt => true, :selected => @test_plan_template_id) %>
<% end %>
4

2 回答 2

3

You can use a hidden field. Like this:

<%= hidden_field_tag "test[test_page]", @test_plan_template_id %>
于 2012-04-30T11:13:01.610 回答
0

Try adding an html name option like this:

<%= collection_select(:test_plan,:test_plan_template_id, @testplantemplates, 
:id, :title, :prompt => true, :selected => @test_plan_template_id), 
:name => "test[test_page]" %>
于 2012-04-30T17:24:36.407 回答