question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In "creationView" I can't use two fields of type "reference" related to the same entity.

See original GitHub issue

In “creationView” I can’t use two fields of type “reference” related to the same entity. If I use two fields the data is duplicated in the select input, if I used three fields the data are tripled, and so on.

Entity Wallet:

"wallets": [{
    "id": 1,
    "currency": "ZZ",
    "owner": 1,
    "balance": "123123",
    "country": "ASD",
    "modification": "2015-10-13T15:20:43.366371Z",
    "creation": "2015-10-13T15:20:43.366371Z"
}]


"charges": [{
    ...
    "source_wallet": 5
    "beneficiary_wallet": 8
    ...
}]

The Create View

charges.creationView()
    .title('Create new Charge')
    .fields([
        ...
        nga.field('source_wallet', 'reference')
            .label('Source Wallet')
            .targetEntity(admin.getEntity('wallets'))
            .targetField(nga.field('id'))
            .singleApiCall(ids => ({ 'id': ids })),
        nga.field('beneficiary_wallet', 'reference')
            .label('Beneficiary Wallet')
            .targetEntity(admin.getEntity('wallets'))
            .targetField(nga.field('id'))
            .singleApiCall(ids => ({ 'id': ids })),
        ...
    ]);

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
orgitocommented, Feb 16, 2016

+1 My workaround for that is to create different variables to use as reference in .targetEntity().

...
var usera = nga.entity('users');
var userb = nga.entity('users');
...
nga.field('usera_id', 'reference').targetEntity(usera),
nga.field('userb_id', 'reference').targetEntity(userb),
...

I even use .permanentFilters() to show different values for each field.

0reactions
yogipatelcommented, Aug 12, 2016

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Field Configuration - marmelab/ng-admin - GitHub
The reference type specializes the Field type, so it supports the same label , order , map , list & validation options. Additional...
Read more >
JPA Entity with two fields of the same type - Stack Overflow
It's complaining that it doesn't know how to map the author field. You can provide a mapping similar to how you mapped writtenTo...
Read more >
Allow for an entity reference field to reference multiple ... - Drupal
I have a requirement to create an "associated media" field that can reference galleries (entity = node, bundle = gallery), videos (entity ......
Read more >
OpenPages with Watson 8.3 Fix List - IBM
A comprehensive list of defect corrections for major releases, refresh packs and fix packs of IBM OpenPages with Watson 8.3. Details of the...
Read more >
marmelab/ng-admin - Gitter
Hi all! I'm quite new to ngadmin. I need two related choices fields. I try to use country/cities example, but it doesn't work....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found