Hi all,
I’m trying to write a plugin that extends a files field to add a cropping interface in the panel (on a page block). The cropping part is working fine, and I’ve tried it a few different ways, but as soon as the page is saved my crop data is lost.
Currently I’m trying to save it all as a json string with the files list as a field and the crop data as a field, like:
{ crop: …, files: […]}
My vue file just calls the k-files-field like so:
<k-files-field
:value="selectedFiles"
:selected="selectedFiles"
:endpoints="endpoints"
name="Image"
:multiple="false"
search="true"
type="image"
:required="required"
@input="filesUpdated"
/>
and my index.php is just:
Kirby::plugin('wsp/crop', [
'fields' => [
'crop' => [
'extends' => 'files'
]
]
]);
If I crop an image it emits the new values fine (as a string), and if I reload the page, the field gets instantiated with the correct values. The images are there and so is the crop data. But as soon as I click “Save” and reload the page, the new value is [ ]
(a non-string array)
I’ve also tried adding the crop data directly to the files as an extension of the k-files-field, but that data gets erased too.
I’m assuming there’s some kind of custom saving logic or validation on the php side I can’t find. I’ve tried to look in the kirby repos, but can’t seem to figure it out.
Any help would be greatly appreciated. Thanks!