-
Is there a way to remove fields from a page? I tried:
$page->update([‘key’ => null]);
But that doesn’t seem to do anything.
-
Is it possible to store fields as an array? I tried:
$page->update([‘key’ => [‘a’, ‘b’, ‘c’]]);
But ->update
only seems to store strings. I could probably store it as JSON, but I’d prefer to use a kirby method if it exists.
Thanks!!!
I don’t think no 2 is possible, the update function merges $page->content()->toArray()
with your input data.
No. 1: I don’t know of any function that deletes a field. You can set it to empty, but that’s probably not what you want.
Thanks again!
I’m just going to store values as JSON. Since no one (even myself) will ever need to see the raw content, there’s really no need to make things that consistent.
Thanks, I’ve bookmarked this! The JSON method is working fine for now but I eventually plan on making it editable by the user directly, so this is great.