我目前在我的应用程序中有一个使用选择表单助手的表单。它访问 2 个变量:
@user = ['JM', 'JH', 'RY']
@name = ['JASON', 'JOHN', 'RYAN']
我的表格如下所示:
<%= form_for(:event, :url => {:action => :update, :id => @event.id}) do |e| %>
<table>
<tr>
<th>Initails</th>
<td><%= e.select(:initials, (@user)) %></td>
<th>Priroty</th>
<td><%= e.select(:priroty, (1..10)) %></td>
</tr>
<tr>
<th>Name</th>
<td><%= e.select(:name, (@name)) %></td>
<th>Event</th>
<td><%= e.text_field(:event_name) %></td>
</tr>
<tr>
<th>Deadline:</th>
<td><%= e.datetime_select(:deadline, :order => [ :month, :day]) %></td>
<th>Complete ?</th>
<td><%= e.check_box(:complete) %></td>
</tr>
<tr>
<th>Event Description</th>
<td><%= e.text_area(:event_description, :size => '80x10') %></td>
</tr>
<tr>
<th>Comments</th>
<td><%= e.text_area(:comment, :size => '80x10') %></td>
</tr>
</table>
<table>
<div class="actions">
<%= e.submit %>
</div>
</table>
<% end %>
当我选择我的姓名首字母并显示@user 时,我正在尝试填充使用@name 的名称字段。有人知道如何关联 2,所以当我选择 JM 时,它会在名称字段中拉出 Jason?