how to embed raw html in active_admin formtastic

送分小仙女□ 提交于 2019-11-29 07:48:56

You can insert a div or javascript like this:

   f.form_buffers.last << content_tag(:div, "Div content here")
   f.form_buffers.last << javascript_tag("alert('hi');")

In the current ActiveAdmin the form_buffers is deprecated. Instead it's possible to do the following:

insert_tag(Arbre::HTML::Div) { content_tag(:span, "foo") }

Active admin created a DSL on top of Formtastic according to their docs

https://github.com/activeadmin/activeadmin/blob/master/docs/5-forms.md

So you can now do:

form do |f|
  f.semantic_errors(*f.object.errors.keys)

  import_errors = self.controller.instance_variable_get("@errors")
  if import_errors.present?
    ul class: 'errors' do
      import_errors.each do |e|
        li e
      end
    end
  end
 # ...
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!