2013-07-17 36 views
3

我安裝了gem'redactor-rails',它是文本編輯器。我想用它與simple_form,但我有麻煩。redactor rails不能與simple_form一起使用

如果我用它來與非標準導軌幫手的form_for:

<%= form_for(@profile) do |f| %> 
    <%= f.text_area :aboutme, placeholder: "Content goes here...", :class => "redactor"%> 
<% end %> 

它的所有權利。我可以用粗體,斜體編輯文本等

但是,當我嘗試使用simple_form使用它:

<%= simple_form_for(@profile) do |f| %> 
<%= render 'devise/shared/error_messages', object: f.object %> 
<%= f.input :aboutme, input_html: { class: "redactor", as: :text } %> 
<%= text_area_tag :editor, "Ghbtd", :class => "redactor", :rows => 40, :cols => 120 %> 
<%= f.submit "Сохранить", class: "btn btn-primary" %> 
<% end %> 

我特別從通常的形式添加text_area_tag,它是創建兩個字段,一個字段(text_area_tag )它的效果很好,但用simple_form創建的Redactors字段變成了簡單的字段,我不能用Redactors修改它,我只能輸入文本,它的寬度與表單中的其他字段一樣寬,但是text_area_tag的寬度更大。 as:text屬性應該在simple_form中創建字段text_area,爲什麼它不起作用?

+1

爲什麼你正在使用「text_area_tag」? – sunil

回答

1

對於誰仍面臨這種問題的人,對上述問題做到像這個 -

<%= simple_form_for(@profile) do |f| %> 
    <%= f.input :aboutme, label: 'Your label', :as => :text, :input_html => { :class => "redactor" } %> 
    <%= f.submit "Сохранить", class: "btn btn-primary" %> 
<% end %> 
相關問題