Thanks again for pointing us in the mixedfield direction.
We're sorta stumped on creating this type of field.
We have an admissions form with a school field and we'd like the user to fill out "School, Location, Year, GPA, Major".
So we created an ItemSchema with those attributes. Then using the example have a const called SchoolWidget using the example in the training with schema=ItemSchema.
When we render in the browser I get Object | object reference instead of the nice widget in the storybook or code example. The browser console displays "Warning: Failed prop type: Invalid prop value of type object supplied to TextWidget, expected string." which leads me to think that we're trying to pass something as a value to the wrong object type?
What do you think? any comments/suggestions appreciated.
So you may be missing (or maybe it's not properly done) the part in the training that says:
Register this widget for the backend field of your choice in your apps configuration config.js . The following config code registers the custom Plone HistoryWidget for Plone Classic fields with widget “history_widget”.
Thank you for responding! I have been modeling my widget according to the history widget example in the plone 6 tutorial. Here is some of the code below:
Unfortunately, I am still getting [object Object] in the datagridfield/mixedfield positions when opening the add content type for the content type i would like to create. What else would I need to do here?
i remember having big troubles to get datagrids to work with more complex data then strings or ints; like objects and references. which made me jump over to yafowil.
Warning: Failed prop type: Invalid prop value of type object supplied to TextWidget, expected string."
I had the same issue following the example provided here.
As @tiberiuichim suggested the problem was that the widget had not been properly registered in config.js.
Registering it via the field ID as explained here solved the issue for me.
Please be sure to use plone.restapi version >= 7.3.0
The feature "Adjust JSONField adapter to include widget name to use in serialization" is introduced in version 7.3.0