I'm using the repeater field on my resource which looks and works great for editing, but how do I display the json data it saves to my detail page? I assume I use the KeyValue field for displaying but how do I access the json data correctly within that field? The Repeater fields saves json like:
[
{
"type": "location-contact",
"fields": {
"name": "mike",
"email": "[email protected]"
}
},
{
"type": "location-contact",
"fields": {
"name": "john",
"email": "[email protected]"
}
},
{
"type": "location-contact",
"fields": {
"name": "Mary",
"email": "[email protected]"
}
}
]
However the KeyValue field expects the json to look like:
{
"name": "mike",
"email": "[email protected]"
}
How do I access the json data in the first example (since that's how the Repeater field dumps it in) using either the Repeater or KeyValue field? The docs on the Repeater field mention nothing of the detail view, so I'm assuming we use the KeyValue field.
Repeater::make('Location Contacts', 'location_contacts')
->repeatables([
LocationContact::make(),
])->asJson(),
// Is there a way this field can display json data on detail view?
or
KeyValue::make('Location Contacts', 'location_contacts'),
// Do I use ->withMeta to display the json data on detail view?