simple_form'form-inline'无效

Ryu*_*uji 2 ruby-on-rails simple-form slim-lang

我正在尝试将两个输入(名字和姓氏)彼此相邻.

这是我的代码,它目前只显示两行输入窗口.

= simple_form_for @user, html: {class: 'form-inline'} do |f|
  = f.fields_for :profile, @user.profile || Profile.new, html: {class: 'form-inline'}  do |p|
     .form-1
        .form-1-detail
           .input-text
              = f.input :last_name, required: true
           .input-text
               = f.input :first_name, required: true
Run Code Online (Sandbox Code Playgroud)

我现在确定如何使它们显示为内联.谁能帮我?

谢谢!

更新.这是从中生成的实际HTML

= simple_form_for @user, html: {class: 'form-inline'} do |f|
 = f.fields_for :profile, @user.profile || Profile.new do |p| # removed form-inline here
  .form-1
    .form-1-detail
      .form-group
        = f.input :last_name, required: true
      .form-group
        = f.input :first_name, required: true




</div><form class="simple_form form-inline" novalidate="novalidate" id="new_user" action="/users" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="DhQSodBk8kxdE6q9uPJDKSs9FfxCNLyXFYT3bZ42HlZfHefxfG3BDq9qkFpxkX7MBZI4Mc4Wje6LKw7Gp1YcjQ==" />
  <div class="form-1">
    <div class="form-1-detail">
      <div class="form-group">
        <div class="input string required user_last_name"><label class="string required" for="user_last_name"><abbr title="required">*</abbr> ?</label><input class="string required" placeholder="?" type="text" name="user[last_name]" id="user_last_name" /></div>
      </div>
      <div class="form-group">
        <div class="input string required user_first_name"><label class="string required" for="user_first_name"><abbr title="required">*</abbr> ?</label><input class="string required" placeholder="?" type="text" name="user[first_name]" id="user_first_name" /></div>
      </div>
    </div>
  </div></form>
Run Code Online (Sandbox Code Playgroud)

dan*_*ith 8

你应该安装simple_form包装器:

rails generate simple_form:install --bootstrap
Run Code Online (Sandbox Code Playgroud)

从那里你可以使用它的相应包装器构造一个inline_form:

simple_form_for @user, wrapper: :inline_form, html: { class: 'form-inline' } ...
Run Code Online (Sandbox Code Playgroud)

他们有一个示例应用程序:https://github.com/rafaelfranca/simple_form-b​​ootstrap

使用它的具体观点是(抱歉它是ERB):

https://github.com/rafaelfranca/simple_form-b​​ootstrap/blob/master/app/views/examples/_inline_form_sf.html.erb