2014-06-24 15 views
2

我需要添加一個數據屬性到由Active Admin創建的表單標籤。Active Admin - 我可以向表單標籤添加數據屬性嗎?

這是當前的活動聯繫表單代碼...

ActiveAdmin.register Pdf do 
     menu parent: "Video Series" 
     PDFTYPES = { 
     outline: "Outline", 
     transcript: "Transcript" 
     } 

     member_action :getvideos do 
     unless params[:id].blank? 
     render :json => Video.where(video_series_id: params[:id]).to_json.html_safe 
     end 
     end 

     member_action :clearvideo do 
     #binding.pry 
     #puts "pdfID : #{id}" 
     end 

     index do 
     column :title 
     column :description 
     column :pdf_type 
     column :created_at 
     column :updated_at 
     actions 
     end 

     form do |f| 
     f.inputs "Pdf Content" do 
      f.input :title 
      f.input :url 
      f.input :description 
      f.input :pos 
      f.input :video_series, as: :select, include_blank: true, collection: VideoSeries.all.map { |video| ["#{video.title}", video.id] } 
      f.input :pdf_type, as: :select, include_blank: true, collection: PDFTYPES.sort.map {|key,val| [val,key]}, input_html: { data: {pdf_id: pdf.id} } 
      f.input :video, as: :select, include_blank: true, collection: Video.where(video_series_id: f.object.video_series_id).map { |video| ["#{video.title}", video.id] } 
      f.actions 
     end 
     end 
    end 

你可以在我的代碼見上面我是如何創建一個名爲第二選擇輸入數據屬性「pdf_type」 - 「input_html:{data:{pdf_id:pdf.id}}。「

我想在窗體標籤上的這個數據屬性。這可以通過Active Admin完成嗎?

謝謝, 克里斯

回答

5

你可以做這這樣

form html: {data:{ attribute: "value"}} do |f| 
    #Your code there 
end 
相關問題