我正在使用ActiveAdmin构建一个表单,它允许用户将Quote
作为嵌套属性添加到Job
表单中。我希望将Quote
和Job
的属性组合到同一个表单块中。
我成功地实现了这一点,但是我的嵌套:quote
块呈现了一个嵌套的fieldset
元素。我只想让它呈现li
元素,而不是包装部分。
我当前的代码如下所示:
ActiveAdmin.register Job do
form do |f|
f.inputs "Quote Details" do
f.inputs "", :for => [:quote, f.object.quote || Quote.new] do |f|
f.input :quote, :input_html => { disabled: !current_admin_user.role?(:admin) }, hint: f.object.quote.present? ? link_to(f.object.quote.identifier, f.object.quote.url) : false
f.input :quote_cache, as: :hidden
f.input :_destroy, :as => :boolean if f.object.quote.present?
end
f.input :quote_accepted# if f.object.quote.present?
f.input :quote_accepted_date, as: :datepicker# if f.object.quote_accepted
end
end
end
我如何编辑它,使:quote
块没有环绕?
发布于 2021-04-14 20:24:50
这个问题很老了,但我也有同样的问题,这个答案可能会对某些人有所帮助。
我不能只渲染一个字段集,但我通过编辑第二个f.inputs
的css样式来修复它。我在第二个f.inputs
中添加了一个style: 'border: none'
。您可以添加类而不是内联样式。
如下所示:
ActiveAdmin.register Job do
form do |f|
f.inputs "Quote Details" do
f.inputs :for => [:quote, f.object.quote || Quote.new], style: 'border: none' do |f|
f.input :quote, :input_html => { disabled: !current_admin_user.role?(:admin) }, hint: f.object.quote.present? ? link_to(f.object.quote.identifier, f.object.quote.url) : false
f.input :quote_cache, as: :hidden
f.input :_destroy, :as => :boolean if f.object.quote.present?
end
f.input :quote_accepted# if f.object.quote.present?
f.input :quote_accepted_date, as: :datepicker# if f.object.quote_accepted
end
end
end
https://stackoverflow.com/questions/30356222
复制