marmelab / marmelab/ng-admin

Extending ReferenceManyField with new type cause dupes choices to appear

Open
#649 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
3.9k
Forks
703
PR merge metrics
No merged PRs in 30d

Description

Hi!
I managed to extend `ReferenceManyField` like this :

```
import ReferenceManyField from 'admin-config/lib/Field/ReferenceManyField';
class ReferenceManyCustomField extends ReferenceManyField {
constructor(name) {
super(name);
this._type = 'reference_many_custom';
}
}
export default ReferenceManyCustomField;
```

But now the `choices` displayed include the current field value.
If I remove the line where I change the `_type` property, it goes back to normal.
Any hints on why this is happening?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in admin-config/lib/Field/ReferenceManyField and compare the behavior with and without changing _type to reference_many_custom. Reproduce the custom subclass case and verify that the choices no longer include the current field value when the type is extended.

Written by the indexing model from the issue text.

Assessment

Tech stack
angularjs, javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.