simple_form:一行上的嵌套模型表单元素?

时间:2012-06-18 19:00:07

标签: css ruby-on-rails twitter-bootstrap nested-attributes simple-form

我使用嵌套的模型表单来编辑客户端的所有电话号码。我认为如果我将所有手机属性放在一行上,simple_form显示它的方式可以改进。

这是我目前的代码:

.main
  .form-inputs
    = f.input :lname, label: t('client.lname')
    = f.input :fname, label: t('client.fname')
    = f.simple_fields_for :phones do |phones_form|
      = phones_form.input :phone, label: 'Phone'
      = phones_form.input :kind, collection: [:home, :work, :cell, :unknown], label: 'Kind'
      = phones_form.input :_destroy, as: :boolean, label: 'Delete?'

  .form-actions
    = f.button :submit, value: t('client.submit'), class: 'btn btn-primary'

它产生以下内容: enter image description here

是否可以将嵌套模型的表单属性放在一行(如下所示)? enter image description here

1 个答案:

答案 0 :(得分:1)

是的,这是一个CSS问题。简而言之,你就是这样写的:

= phones_form.input :kind, collection: [:home, :work, :cell, :unknown], label: 'Kind', style: 'width: 50px;'