简体   繁体   English

如何在没有fieldset的情况下创建一个formtastic嵌套输入?

[英]How do I create a formtastic nested input without fieldset?

I have a table User that inherits from a table called Person 我有一个表继承自一个名为Person的表的User

Long story short, instead of having to do the following: 长话短说,而不是必须做以下事情:

f.inputs 'Something' do
  f.inputs for: :person do |f|
    f.input :name
    f.input :surname
  end
  f.input :account
end

This generates an fieldset inside an ol , which is by itself invalid, but that's not what worries me. 这会在ol生成一个fieldset ,这本身就是无效的,但这并不是我担心的问题。 I want to get rid of the fieldset so all the attributes are shown at the same level. 我想摆脱的fieldset ,这样所有的属性都在同一水平所示。

f.inputs 'Something' do
  f.input :name, for: :person
  f.input :surname, for: :person
  f.input :account
end

Of course that is not valid, there is not such thing as a for: in the input. 当然这是无效的,在输入中没有for:for。

I was thinking about using delegate, but then I though that I also have a lot of accepts_nested_attributes_for in the Person model and them would broke. 我正在考虑使用委托,但后来我在Person模型中也有很多accepts_nested_attributes_for ,它们会破坏。

Also the Person table is being inherited by another model. Person表也​​被另一个模型继承。

There is any gem that transparentize this and allow me to just inherit the model? 有没有透明化的宝石,让我继承模型?

Use semantic_fields_for instead of inputs : 使用semantic_fields_for而不是inputs

f.inputs 'Something' do
  f.semantic_fields_for :person do |p|
    p.input :name
    p.input :surname
  end
  f.input :account
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM