Links/References all have the type `Link` which makes them not distinguishable
See original GitHub issueI try to build a Contentful App using the @contentful/default-field-editors
. I am using the FieldExtensionSDK
to figure out the field type by looking at sdk.field
which is an object of the class FieldAPI. Regarding to this source the field type can be one out of these types:
- {type: “Symbol”}
- {type: “Text”}
- {type: “RichText”}
- {type: “Integer”}
- {type: “Number”}
- {type: “Date”}
- {type: “Boolean”}
- {type: “Location”}
- {type: “Object”}
- {type: “Link”, linkType: “Asset”}
- {type: “Link”, linkType: “Entry”}
- {type: “Array”, items: {type: “Symbol”}}
- {type: “Array”, items: {type: “Link”, linkType: “Entry”}}
- {type: “Array”, items: {type: “Link”, linkType: “Asset”}}
This works correct for all field types except for Links and Arrays (the last 5 items from the list). For any link whether it is {type: "Link", linkType: "Asset"}
, {type: "Array", items: {type: "Symbol"}}
or one of the other 3 reference types the FieldAPI
object I receive looks like:
{ id: ..., locale: ..., required: ..., type: "Link", items: undefined, ... }
Since the type
field is always Link
and items
field is always undefined
it is not possible to render the correct default field editor for this field. Though it seems to be possible to fetch the more detailed information from the API (mentioned above) and the default-field-editor
supports these different types aswell, see here.
So my question is if this is a bug or maybe this is a feature which can be implemented? Maybe the information is somewhere hidden and I do not see it? I am happy to provide more information if needed.
Package versions
"@contentful/app-sdk": "^4.12.1",
"@contentful/default-field-editors": "^1.2.38",
"@contentful/f36-components": "^4.21.0",
"contentful-management": "^10.18.1",
"react": "^16.14.0",
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
@brokelyn I do have the exact same problem right now. Another interesting property, at least for my use case, would be the appearance applied to that field.
No not really. I will try to make a small example of what I try to achive or where my problem is.
I have Content model
A
which has only one field calledMediaFiles
. This field is of typeMedia
withMany files
selected. As appearance I choose my own App.When I now try to create an instance/object of this Content model
A
I expect my App to use thedefault-field-editor
package and render aMultipleMediaEditor
since the fieldMediaFiles
is of typeMedia
and can contain multiple files.Unfortunately the
default-field-editor
wont render anything since it cant determine the type of the fieldMediaFiles
. Looking at thesdk
object I pass todefault-field-editor
I can see that the type I get from theFieldExtensionSDK
(part of the App SDK) is looking like this:but I would expect it to look like this (more information so I can render the correct component):
So basically what is described here, just passing the
FieldExtensionSdk
and thedefault-field-editor
figures out which type of field it needs to render is not working for references.Another reference is here under
Getting the type of the field
.I hope now it is a bit more clear. Let me know if not!