#RenderFields with runtime generated schema

3 messages · Page 1 of 1 (latest)

median raptor
#

Hi,
I'm attempting to use the RenderFields component with a schema generated at runtime. Here's my usage

<RenderFields fields={schemaTree} parentPath="" parentIndexPath={''} parentSchemaPath={''} permissions={perms} readOnly={false} />

where schemaTree is

[ { "name": "items", "type": "array", "label": "Items", "fields": [ { "name": "item_skew", "type": "text", "label": "Item Skew", "defaultValue": "" } ], "labels": { "singular": "Items", "plural": "Itemss" }, "minRows": 0, "defaultValue": [] } ]

and perms is

{ "items": { "read": true, "create": true, "update": true, "fields": { "item_skew": { "read": true, "create": true, "update": true } } } }

and the initial form state has no entry for the items array.

At this point, the RenderFields component only renders the items label and "add items" button
After clicking the "add items" button, the RenderFields component displays the row loading UI, but never the "item_skew" field.
And the following entries for the items array are added to the form state

"items.0.id": { "initialValue": "683ce0623cbc395dc8a5127b", "passesCondition": true, "valid": true, "value": "683ce0623cbc395dc8a5127b" }, "items": { "disableFormData": true, "rows": [ { "id": "683ce0623cbc395dc8a5127b", "collapsed": false, "isLoading": true } ], "value": 1 }

The collection config doesn't define the fields in schemaTree, these fields are generated after the admin ui page loads for the collection doc.
Am I incorrectly initializing? in general where am I going wrong? Is RenderFields the way to go? Thanks!

frank garnetBOT
median raptor