platanus / activeadmin_addons

Extends ActiveAdmin to enable a set of great optional UX improving add-ons
MIT License
763 stars 288 forks source link

[BUG]: Search select doesn't work with non resource form #478

Open mrudult opened 1 year ago

mrudult commented 1 year ago

Given the following custom page:

ActiveAdmin.register_page "Invite Account" do
  content do
    active_admin_form_for :invitation, url: invite_account_admin_accounts_path, method: :post do |f|
      f.inputs do
        f.input :first_name, label: 'First name', required: true
        f.input :last_name, label: 'Last name'
        f.input :email, label: 'Email', required: true
        f.input :post_id, as: :search_select, url: proc { admin_posts_path }, fields: [:post_name], display_name: "post_name", order_by: "post_name_asc"
      end
      f.actions do
        f.action :submit, label: 'Submit'
      end
    end
  end
end

Throws error:

ActionView::Template::Error (blank object given): 1: # frozen_string_literal: true 2: insert_tag active_admin_application.view_factory["page"]

app/admin/pages/invite_account.rb:8:in block (4 levels) in <main>' app/admin/pages/invite_account.rb:4:inblock (3 levels) in

' app/admin/pages/invite_account.rb:3:in `block (2 levels) in
'

The search_select_filter works fine. Any help will be appreciated.

imsinu9 commented 1 year ago

@mrudult you may want pass @object (@invitation || resource) rather :invitation below: active_admin_form_for :invitation