key-value and json arrays: {closure}(): Argument #1 ($value) must be of type ?string, array given
Hey all,
I'm working on an admin section for my portfolio page.
The data is from a bunch of Markdown files with some frontmatter; this frontmatter has been converted and stored as json in a sqlite database. When editing the Project, I chose to display the frontmatter with a KeyValue form component. After trying to save an instance without changing the values (meaning they should be valid), I get the following error:
Could it be that an array value is incompatible with the KeyValue component? Or am I doing something wrong ?
I'm working on an admin section for my portfolio page.
The data is from a bunch of Markdown files with some frontmatter; this frontmatter has been converted and stored as json in a sqlite database. When editing the Project, I chose to display the frontmatter with a KeyValue form component. After trying to save an instance without changing the values (meaning they should be valid), I get the following error:
Could it be that an array value is incompatible with the KeyValue component? Or am I doing something wrong ?
Solution
Looking at it, you are storing as an array but we load that magically and it renders ok. But it should always be stored as a string in a keyValue.... you could look to cast it to a string with attributes.
If you are insistent on storing it as an Array you can use this model class for your project using the get/set attributes
If you are insistent on storing it as an Array you can use this model class for your project using the get/set attributes
