Is there a way to create a data binding directly to a content item custom field?
Currently, I’m extracting the custom field values from the downloaded content item JSON on my back end, feeding it back to the content item’s state using the
data prop, then binding on state.
I’d like to cut out the middleman and just bind directly to my fields.
Hey @ersin !
This is indeed possible, though does require a bit of code in the binding / wherever you intend to use this data.
Basically, within custom JS I would recommend either setting the value to state by putting:
state.whatever = context.builderContent.data.whatever
Or, in your data binding you can access directly with
I think there is a world where we eventually add the ability for a custom field to be added to state as a flag on the field itself, but for now this is the best practice route.
If you think that is a use case you will use a lot, I recommend submitting a feature request to our ideas board at ideas.builder.io !
Hope this helps !