2013-10-08 111 views
-1

我使用简单形式与引导和形式水平类。我有一些输入,我想在一行中进行分组。Rails 3简单形式与引导和一组内联输入

例如。

 
Description  : |____________________________________________________________| 
Date/Month/year : |__________________| |__________________| |__________________| 

我试过如下:

<%= simple_form_for(@example, :html => { :class => 'form-horizontal' }) do |f| %> 
    <%= f.input :description %> 
    <%= f.input :date, :label => "Date/Month/Year", :wrapper => :append do %> 
    <%= f.input_field :date %> 
    <%= f.input_field :month %> 
    <%= f.input_field :year %> 
    <% end %> 
<% end %> 

但后来我收到以下错误消息

 
undefined method `+' for nil:NilClass 

这会触发第二<%= f.input_field %>

+0

我试过顶部投票答案在这里(http://stackoverflow.com/questions/9449481/多输入单线与twitter的引导和简单形式2-0?rq = 1),但我得到了错误消息'未定义的方法'+'为零:NilClass' on块中的第二个input_field。 – ejenns

回答

0

您需要使用标签:div class="form-inline"

,然后为日/月/年你需要把:

<%= f.label :date_variable, "DATE: " %> 
<%= f.date_select :date_variable, use_short_month: true %> 

希望帮助

+0

我更新了我的问题以提供更好的描述,并且您的答案将无法使用。不过谢谢 – ejenns