Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependant select boxes - sending no value when mutliple select box is empty #7

Open
zorec opened this issue Jan 31, 2014 · 0 comments

Comments

@zorec
Copy link
Collaborator

zorec commented Jan 31, 2014

Given the following schema project has_many tasks. Employee has_many projects and has_many tasks through projects.

class Employee < ActiveRecord::Base
  has_many :projects, inverse_of: :employee
  has_many :tasks, through: :projects

  rails_admin do
    edit do
      field :projects
      field :tasks do
        options_source_params do
          { "f[project_id_in]" => bindings[:object].try(:project_ids) || [-1] }
        end
        html_attributes do
        { data: { 
          # set project's field as dependent select box
          "dependant-filteringselect" => "field=project_ids",

          # post parameters
          "dependant-param" => "f[project_id_in]" }
        }
        end
      end
      field :name
      # other fields
    end
  end

The problem is when project field is empty. Then no project_id is sent in options request to TasksController. This means that all tasks are shown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant