I am using Butterbean in my project, and I have a custom color picker control.
I use the same control in the customizer, and I recently added some features that require storing more data than just the color. Using the customizer api, I was able to connect multiple settings to a single control.
I am trying to replicate this in the Butterbean version of the control, but am a bit stuck. How can I save and retrieve the values of multiple inputs within a single control? I see that there are different types of settings (‘multiple’ ‘array’ etc) but am unsure how to utilize these.
My current color control files are nearly identical to the standard Butterbean color picker. But I want to add a checkbox and a hidden input field to the template.
In your to_json() method, you’ll need to specifically get any data that you want to pass to your control’s template. The default setting will be automatically set up. It’s the default. Any custom ones will need to be set up separately.
So, in your custom to_json() method, you’d do something like this: