ng-admin icon indicating copy to clipboard operation
ng-admin copied to clipboard

Error when using the same entity as reference twice

Open Wtower opened this issue 9 years ago • 2 comments

Scope

An Angular error occurs when attempting to use the same entity as reference to two different fields in a creationView.

Prerequisites

  • [email protected] due to #1201 #1203
  • Documentation checked as much as possible
  • Unable to find a similar issue

Description

In the following configuration:

    productFamily.creationView().fields([
      nga.field('name'),
      nga.field('parent', 'reference')
        .targetEntity(productFamily)
        .targetField(nga.field('name'))
        .label('Parent family'),
      nga.field('parent2', 'reference_many')
        .targetEntity(productFamily)
        .targetField(nga.field('name'))
        .label('Parent family 2'),

Although the above is just an example, I have a different actual use case that I need to assign a reference to 2 different fields, one of which is multiple select. This use case involves the assignment of specification entities to a field named product_specs and to a field named product_sku_specs (multiple).

Of course I may be doing something wrong altogether, since I am still trying to find my way out. Btw, congrats for the project.

The error is:

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: $item in $select.selected, Duplicate key: object:171, Duplicate value: {"value":"57dab634c7bfa33b623ee865","label":"Test"}
http://errors.angularjs.org/1.4.10/ngRepeat/dupes?p0=%24item%20in%20%24sele…%22value%22%3A%2257dab634c7bfa33b623ee865%22%2C%22label%22%3A%22Test%22%7D
    at angular.js:68
    at angular.js:28030
    at r (angular.js:16068)
    at h.$digest (angular.js:16203)
    at h.$apply (angular.js:16467)
    at HTMLDivElement.<anonymous> (angular.js:24076)
    at Ke (angular.js:3374)
    at HTMLDivElement.n (angular.js:3362)

Also, although the specific API call should return only 1 record ("Test"), and possibly be called only once, there are 2 API calls to the same URL, and in the second field 2 records are displayed (Test, Test). This does not happen if I remove the any of the fields.

Expected behavior: No error, a single record for the reference_many

Actual behavior: The above error, 2 records for the reference_many field.

Wtower avatar Sep 21 '16 16:09 Wtower

This is a BUG, I got the same error too, probably they will fix it soon.

shifatul-i avatar Oct 30 '16 20:10 shifatul-i

Is there any update on this issue ? I'm having the same problem and could not find a way to solve it.

Thanks!

emathias avatar Feb 02 '17 15:02 emathias