ng-admin: embedded_list reference fields do not work
I have an edit view with an embedded list field that has sub-fields of reference type and they do not work properly. There is no call to the rest api asking for the list in this example.
nga.field('editResultsId', 'embedded_list')
.label('Edit Results')
.targetFields([
nga.field('fileSystemId', 'reference')
.label('File System')
.targetEntity(file)
.targetField(nga.field('name'))
.validation({ required: true }),
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 11
- Comments: 20 (5 by maintainers)
I had a quick look at this today but wasn’t able to make much progress - had to figure out how things hang together. Leaving some notes as @etdev was keen to look at this also.
Crud/routing.js
creates a bunch ofui-router
resolve definitions based on the model coming out of theadmin-config
library.It looks like
lib/Utils/ReferenceExtractor
inadmin-config
is the culprit, it only looks at the top level object and doesn’t traverse complex fields.Took a quick stab at fixing this but I’ve run out of time to look at it this week and it doesn’t work. Here’s the code so far, it’s a recursive function to find all the reference fields during a call to
getReferences
.Cheers 😃
WORKAROUND – While waiting for the pull-request to be completed, I found an easy workaround. Just add the same reference field to your top level object (make it hidden, non-editable, not required). As long as you use the same object in .targetEntity() in both the top level and embedded, you will get a populated list. Below I just used an empty label and non-editable field, but you can use CSS to hide the field row as well.
I tried to fix it by this PR https://github.com/marmelab/admin-config/pull/75
This just worked for me:
The singleApiCall can be ommited I think, because it’s just for MongoDB.
Some notes from my duplicate over at #1145 (sorry, closed now!)
I can confirm this is still an issue in
1.0.0-alpha4
showView
does not perform any retrievals ofreference
objects for renderingcreationView
andeditionView
both load listings and perform remote completion as expectededitionView
does not retrieve thereference
object for rendering. However if the object is returned in the listing of objects used to render the dropdown, this does work as expected.+1 seriously need! is there any workaround?