开发者

How do I create a formtastic nested input without fieldset?

开发者 https://www.devze.com 2023-04-12 04:52 出处:网络
I have a table User that inherits from a table called Person Long story short, instead of having to do the following:

I have a table User that inherits from a table called Person

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.in开发者_运维百科put :account
end

This generates an fieldset inside an ol, which is by itself invalid, but that's not what worries me. I want to get rid of the fieldset so all the attributes are shown at the same level.

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.

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.

Also the Person table is being inherited by another model.

There is any gem that transparentize this and allow me to just inherit the model?


Use semantic_fields_for instead of inputs:

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

精彩评论

暂无评论...
验证码 换一张
取 消