simple_form 日期输入未显示在同一行中
simple_form date input not showing in same line
我的表格中有一个输入日期:
<%= simple_form_for @user, url:wizard_path, html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group do |f| %>
<%= f.simple_fields_for :educations do |b| %>
<%= b.input :school_name %>
<%= b.input :degree %>
<%= b.input :year_started %>
<%= b.input :year_finished %>
<% end %>
<%= f.button :submit, "Continue" %>
or<%= link_to " Skip this step", next_wizard_path%>
<% end %>
我的问题是日期月份和年份输入不在同一行并且看起来很难看(即它显示 3 行,每行一个输入)。我认为 simple_form 的默认行为会在同一行中显示输入的日期,但我的不是。这在 simple_form 中正常吗? (具体用于日期输入)还是我需要通过 css 进行一些配置?请帮助我:(
相关型号:
用户模型:
has_many :educations, dependent: :destroy
accepts_nested_attributes_for :educations
教育模式:
belongs_to :user
环顾四周,我找到了问题的答案here
我希望不用 css 就能解决这个问题,因为我认为 simple_form 有办法处理这种事情。
HTML:
<select id="user_educations_attributes_0_year_started_3i" name="user[educations_attributes][0][year_started(3i)]" class="date required form-control">
<select id="user_educations_attributes_0_year_started_2i" name="user[educations_attributes][0][year_started(2i)]" class="date required form-control">
<select id="user_educations_attributes_0_year_started_1i" name="user[educations_attributes][0][year_started(1i)]" class="date required form-control">
CSS:
.date.required.form-control{
display: inline-block;
width: 32%;
margin-right: 5px;
}
我的表格中有一个输入日期:
<%= simple_form_for @user, url:wizard_path, html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group do |f| %>
<%= f.simple_fields_for :educations do |b| %>
<%= b.input :school_name %>
<%= b.input :degree %>
<%= b.input :year_started %>
<%= b.input :year_finished %>
<% end %>
<%= f.button :submit, "Continue" %>
or<%= link_to " Skip this step", next_wizard_path%>
<% end %>
我的问题是日期月份和年份输入不在同一行并且看起来很难看(即它显示 3 行,每行一个输入)。我认为 simple_form 的默认行为会在同一行中显示输入的日期,但我的不是。这在 simple_form 中正常吗? (具体用于日期输入)还是我需要通过 css 进行一些配置?请帮助我:(
相关型号:
用户模型:
has_many :educations, dependent: :destroy
accepts_nested_attributes_for :educations
教育模式:
belongs_to :user
环顾四周,我找到了问题的答案here
我希望不用 css 就能解决这个问题,因为我认为 simple_form 有办法处理这种事情。
HTML:
<select id="user_educations_attributes_0_year_started_3i" name="user[educations_attributes][0][year_started(3i)]" class="date required form-control">
<select id="user_educations_attributes_0_year_started_2i" name="user[educations_attributes][0][year_started(2i)]" class="date required form-control">
<select id="user_educations_attributes_0_year_started_1i" name="user[educations_attributes][0][year_started(1i)]" class="date required form-control">
CSS:
.date.required.form-control{
display: inline-block;
width: 32%;
margin-right: 5px;
}