以嵌套形式在 activeadmin 中插入静态内容或一些 erb
Insert static content or some erb in activeadmin in nested form
正在尝试在活动管理中呈现有关对象的一些信息:
f.inputs 'Devices' do
f.has_many :devices, new_record: false do |device|
"html or some ERB goes here"
device.input :status_activated, as: :bool
end
end
我尝试了以下方法,发现 here:
device.form_buffers.last << (<<END
<li class="string input optional stringish">
<label class="label">Activate interlock</label>
<div style="display: inline-block;">Dynatherms connected</div>
</li>
END
).html_safe
没有成功。
提前致谢!
insert_tag(Arbre::HTML::Div) { content_tag(:span, "foo") }
似乎已回答(但未被接受)here。
有关详细信息,请参阅 arbre 存储库。
如果你只有一些简单的HTML,就做
f.inputs 'Devices' do
f.has_many :devices, new_record: false do |device|
span "html or some ERB goes here"
device.input :status_activated, as: :bool
end
end
但是,如果您需要更复杂的东西,最好只提取一部分,例如用 form partial: 'form'
替换 form do
块并将表单布局和数据放在 _form.html.erb
文件在 app/views/admin/...
正在尝试在活动管理中呈现有关对象的一些信息:
f.inputs 'Devices' do
f.has_many :devices, new_record: false do |device|
"html or some ERB goes here"
device.input :status_activated, as: :bool
end
end
我尝试了以下方法,发现 here:
device.form_buffers.last << (<<END
<li class="string input optional stringish">
<label class="label">Activate interlock</label>
<div style="display: inline-block;">Dynatherms connected</div>
</li>
END
).html_safe
没有成功。
提前致谢!
insert_tag(Arbre::HTML::Div) { content_tag(:span, "foo") }
似乎已回答(但未被接受)here。
有关详细信息,请参阅 arbre 存储库。
如果你只有一些简单的HTML,就做
f.inputs 'Devices' do
f.has_many :devices, new_record: false do |device|
span "html or some ERB goes here"
device.input :status_activated, as: :bool
end
end
但是,如果您需要更复杂的东西,最好只提取一部分,例如用 form partial: 'form'
替换 form do
块并将表单布局和数据放在 _form.html.erb
文件在 app/views/admin/...