2016-11-26 9 views
0

現在activeadminを使用してネストされたフォームを作成しています。ネストされたリソースの追加ボタンをクリックすると、それぞれのネストされたリソースの入力が表示されます。しかし、リソースの追加ボタンをクリックすることなく、入力をデフォルトで表示したいと思います(つまり、フォームがロードされると入力が表示されます)。 私はActiveAdminのドキュメントに対して自分のコードを再チェックして、さまざまなスタックオーバーフローの投稿をチェックしましたが、進歩はそれほどありませんでした。 form title: 'Create a New Project' do |f| f.inputs 'Basic Information' do f.input :category f.input :name f.input :location f.input :size, sortable: :size do |project| "#{project.size}m2" end f.input :published? f.has_many :project_main_image, heading: 'Project main image', allow_destroy: true, new_record: false do |a| a.input :photo, hint: image_tag(a.object.photo.thumb.url, class: 'active-admin-thumbnail') a.input :orientation end f.has_many :project_descriptions, allow_destroy: true do |a| a.input :contents, as: :ckeditor, input_html: { ckeditor: { toolbar: 'Full' } } end f.has_many :project_gallery_images, allow_destroy: true do |a| a.input :photo, hint: image_tag(a.object.photo.thumb.url, class: 'active-admin-thumbnail') a.input :orientation a.input :row_order end f.actions end endNested FormがActiveAdminのフォームを表示しない

すべてのフィードバックやアドバイス:管理者/ project.rbに次のように

Picture of how the form current looks like

私のコードです。より多くの情報が必要な場合はお知らせください。

答えて

0

これは私が何かしたものです。

あなたはキーワードにして、このようなネストされた属性を取ることができます。

form do |f| 
    f.inputs do 
    f.input :user, input_html: { disabled: true } 
     f.input :name 
     f.input :address 
     f.input :city 
     f.input :country, as: :string 
    end 
    f.buttons 

    f.inputs "Account Information", for: [:account, f.object.account] do |s| 
     s.input :active, as: :boolean 
     s.input :subscription, as: :boolean 
     s.input :expires_on, as: :datepicker 

     s.actions 
    end 
    end 

    controller do 
    def permitted_params 
     params.permit! 
    end 
    end 
end 

希望、これは便利です。

+0

アドバイスありがとうございます。実際にネストされた属性を保存することに問題はありません。ネストされた入力をデフォルトで表示することができません... – Joshua

関連する問題