Skip to content

Issue with nested models and browser validations [v0.7.0-master] #2443

@tagliala

Description

@tagliala

Hi,

We found an issue with the latest released gem, still present in the master branch:

screen shot 2015-10-23 at 22 17 24

Models:

class Team < ActiveRecord::Base
  has_many :players
  accepts_nested_attributes_for :players, allow_destroy: true
end

class Player < ActiveRecord::Base
  validates :name, presence: true
  validates :image, presence: true
end

Rails Admin:

  config.model Team do
    field :players
  end

  config.model Player do
    field :name
    field :image
  end

How to reproduce:

  • In rails admin, go for Team -> New Team.
  • Click on "Add a new player".
  • Click on the trash icon
  • Click on "Save"

Nothing will happen. Check the browser console, you will find:

An invalid form control with name='team[players_attributes][1445630637559][name]' is not focusable.
An invalid form control with name='team[players_attributes][1445630637559][image]' is not focusable.

Workaround:

In rails_admin.rb

  config.browser_validations = false

Please let me know if you have a fast fix to this. I'm not familiar with that part of the source code

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions