Is there a way to back a blueprint field with external data? In my case I save data related to the page in a database. Some of that data I want to make editable in a blueprint structure. I can make it available to the field through ‘computed-values’. But I cannot seem to find a way to save it back to the database when changes have been made.
Any pointers on how to solve this one?
ps. I am looking for a fix from the field’s perspective. As I could hardcode this in a page.update (or simular) hook(s), but that wouldn’t make it that portable IMO.
Sorry for bumping this question, but I would really like some input into this problem. (If I should ask it on a platform from Kirby other than this forum, I would love to know as well).
I know you can create custom fields which can extend the structure field to copy all properties etc… So I was wondering if you can control how (and especially where) the data is stored serverside.
‘Displaying’ data in a structure should be easy as you can use the ‘computed-values’. So the reading part wouldn’t be the problem. But once a page is saved, it should update the database.
I know about the page:update hooks, in which I could ‘catch’ the saved page, and clear the values and push them to the database instead.
The problem is that I only have control over the Field declaration. Not so much how it is used in a blueprint. That means I cannot use the hooks since I do not know which fieldnames were used. Besides, it is rather difficult to identify my field-type amongst others.
So the question can be a little more elaborate, if creating a custom bleuprint-field is not the way to go. Or really simple, if there is a way to hook into the saving from a custom-field-class.
I don’t know, Kirby doesn’t store fields, but a page, so you can manipulate where stuff is stored in the page model, not really on the field level. Although you could probably store stuff from individual fields somewhere else when you overwrite the update method.
Kirby does store the value from a blueprint-field though. And the field is responsible for emitting the value to be stored.
There is a value function you can override to modify/alter the value emited, but that is getting called both storing serverside and retaining for clientside. So how can one separate these 2 calls?
I prefer to not use the page-model way, as i have to know field-names/types for that. I need this component to be stand-alone instead of ‘5-steps-to-intergrate’ (If you know what I mean)