如何在active_admin格式中嵌入原始html [英] how to embed raw html in active_admin formtastic

查看:76
本文介绍了如何在active_admin格式中嵌入原始html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在active_admin模型中构建具有形式的表单。
问题是我需要在表单内部或表单周围直接放置某些脚本标记和其他原始HTML内容。

I'm trying to build a form, with formtastic, inside an active_admin model. The problem is I need a certain script tag and other raw HTML stuff directly inside or around the form.

我正在使用普通表单块进行此操作:

I'm doing it with the normal form block:

form do |f|
    f.inputs :name => "User Details", :for => :user do |user_form|
    user_form.input :first_name, :required => true
    ...

如何嵌入简单的 div 是否在标签之间?
甚至是 script 标签?

How do I embed a simple div tag right in between? Or even a script tag?

我考虑过使用 render:partial ,但我想知道是否可以首先使用上述方法。谢谢!

I thought about using a render :partial, but I want to know if the above method is possible first. Thanks!

推荐答案

您可以像这样插入div或javascript:

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');")

这篇关于如何在active_admin格式中嵌入原始html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆