【问题标题】:Enable html on rails form using formtastic使用formtastic在rails表单上启用html
【发布时间】:2014-07-16 14:42:39
【问题描述】:

我想在我的表单上启用用户的 html 输入。

试过了:= f.input :body, :input_html => {:escape => false} and also {:disabled => false}

现在文本显示为一个块。

如果用户放置:

Lorem Ipsum is simply dummy text `</br>` of the printing and typesetting industry.

应该显示为:

Lorem Ipsum is simply dummy text
of the printing and typesetting industry.

非常感谢您的帮助!!

【问题讨论】:

    标签: html ruby-on-rails ruby formtastic


    【解决方案1】:

    解决了。

    表格f.text_area

    在模型上添加方法

    def body_enable_html
      body.html_safe
    end
    

    并在视图中调用方法

    = @collection_page.body_enable_html
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多