Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].
Hi all,
Has the SiteOrigin builder an other way to save widget data?
I have a plugin with a simple custom widget with just a title and multiselect field. Normally the multiselect saves as a normal single array with the selected values.
When I use this plugin in the builder, this array is saved in another array as 0 key. And when I use 2 instances on the same page, only 1 can have saved values.
Does the widget needs some enhancements to work with the builder?
Hi Frietsje,
We don’t modify how widgets are saved so if your widget saves correctly when added to the standard widgets page it should save without issue when added to SieOrigin Page Builder.
Is your multi-select field a standard select with multiple enabled, or is it something a little more complicated?
Is the code of your widget online somewhere?
Hi Alex,
It’s a standard select with multiple indeed. The widget class is the same as the wordpress tutorial, just with the extra field.
I’ve added two screenshots of the widget, after it’s saved. I output the $instance[‘selectfield’] in both cases.
Normal widget area:
Siteorigin widget area:
Note: if I save a second instance in the builder, the first gets emptied.
Hi Frietsje,
Unfortunately, we’re unable to process attachments at this time. Can you please upload your screenshots to a third party image hosting site like Imgur or vgy.me and send me a link to the images?
Sorry, images are not working. New try on imgur
Hi Frietsje,
Thanks. Can you please provide me with a copy of your widget’s code so I can take a look over it?
Yes, of course:
Hi Frietsje,
Thanks. The issue you’re facing is caused by adding [] to the select name. You shouldn’t need to do this for your select field to work.
Hmm the builder is now processing it correct, but the original widget isn’t finding an array as posted value, so only saves one single value.
I’ll dig into that later, at least the builder is working now and I know where’s the trouble :)
Thanks!
Hi Frietsje,
I recommend giving the the SiteOrigin Widgets Bundle developer docs a look. The SiteOrigin Widgets Bundle isn’t just a series of widgets, it’s an entire development framework that makes making widgets an absolute breeze.
I know, I’ve made a lot of SiteOrigin widgets for a client (I love how easy that is by the way :) ). But this is a separate plugin not specific for the SiteOrigin builder.