0

I've got a select type with 3 fixed options as a clock-type. I can't figure out how to get the clocktype(Which is in my group model) to function properly.

In my HTML it shows the select name as clocktype. In stead of group[clocktype].

Here's my form:

<%= form_for(@group) do |f| %>
  <% if @group.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@group.errors.count, "error") %> prohibited this group from being saved:</h2>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br>
    <%= f.text_field :name %>
  </div>

  <%= select_tag(:clocktype, options_for_select([['one', 1], ['two', 2], ['three', 3]])) %>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
4

1 回答 1

1

你错过了f.前面的,即。f.select. 这会将选择标签与您创建的表单相关联。单独使用select_tag用于与模型没有特别关联的通用表单。

于 2013-10-08T07:16:29.113 回答