2

Hi I have the following code on my view:

//I write a loop here to display some workflows saying wkf.each do |i|
<% if (i write my condition here) %>
  <td style="text-align:left;">
  <%= f.check_box :i, {:checked=>true}%> 
  <%= f.label(i, i)%>
  </td></tr>
<% else %>
  <td style="text-align:left;">
  <%= f.check_box(i)%> 
  <%= f.label(i, i)%>
  </td></tr>
<%end%>

Suppose that there are three workflows 'A', 'B' and 'C' and 'C' meets the if condition, then the parameters being sent are 'A'=>0, 'B'=>0 and 'i'=>'1'. I want it to be sent as 'C'=>'1' in the same way as 'A'=>0.

I know that 'i' =>'1' is sent because i wrote f.check_box :i, {:checked=>true}% instead of <%= f.check_box(i)%>.

Please let me know how to change this so that, the check box is checked by default when the if condition is met and the #{i} would be sent instead of :i

Thanks

4

1 回答 1

7

thef.check_box :i不等于f.check_box(i),区别在于i是变量,while:i是符号,和字符串差不多。:在第一种情况下删除。

<%= f.check_box i, {:checked=>true} %> 
于 2012-08-17T15:00:50.770 回答