简体   繁体   中英

CKEditor on custom page in activeadmin

i got the following issue:

I want to add a form on a custom page (no model) to design an email for mailjet. I already got a custom page and a form with an CKEditor input and an input for the subject. But the subject field isn't shown on the page.

This is my code:

ActiveAdmin.register_page "Mail", namespace: :lku do

  def send_mail

  end

  content do
    panel 'Write mail' do

      semantic_form_for :mail, :url => "lku/send_mail", method: :post do |f|

        f.inputs do
          f.input :subject, :input_html => { :name => 'subject' }
        end
        f.inputs do

        f.input :text, as: :ckeditor, :input_html => { :name => 'text' }
        end
      end
    end
  end
end

And this is the result:

没有主题字段的ckeditor

When I add

f.actions

it looks like this

只需提交按钮

can someone help me please?

I was able to reproduce the problem without having ckeditor. Only the last element of form would display.

I don't know exactly what's going on, but it has something to do with how Arbre renders the content you generate inside the content block.

My solution is this

  1. Transform the form content into .erb and move the form under views/lku/mail/_mailform.html.erb

     <%= semantic_form_for :mail do |f| %> <%= f.inputs do %> <%= f.input :subject %> <%= f.input :text %> <% end %> <%= f.actions %> <% end %> 
  2. Include the form in the page

     content do panel 'Write mail' do render partial: 'mailform' end end 

See if you can still mount the editor by using regular Rails form helpers - https://github.com/galetahub/ckeditor#form-helpers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM