Hi,
I appear to have the exact same issue as described here. I’ve tried modify_form and the siteorigin_widgets_form_options filters but the updated form fields don’t carry through.
Hope you can help.
Thanks
Hi,
I appear to have the exact same issue as described here. I’ve tried modify_form and the siteorigin_widgets_form_options filters but the updated form fields don’t carry through.
Hope you can help.
Thanks
This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.
Hi,
Thanks for getting in touch. I’ve run a few tests and modify_form, and the siteorigin_widgets_form_options filter is working as expected. Can you please provide me with a code snippet of your code? This will allow me to inspect your implementation.
For information on using modify_form, and that filter, I recommend reading the docs here: https://siteorigin.com/docs/widgets-bundle/form-building/modifying-forms/
Kind regards,
Alex
Hi Alex,
Thanks for getting back to me. Those were the docs I was looking at. I’m sure I’m missing something but I can’t quite figure out what!
Here’s the code:
Hi,
Thank you for the snippet. modify_form isn’t triggered when you pass $form_options during the construct. You’ll need to add the categories directly to $form_options or pass an empty $form_options, and set the form options using get_widget_form (the latter being my recommendation in general). I’ll log a note to mention this restriction and suggestion soon.
There’s a typo in the provided snippet. The post_types you’re passing to the autocomplete form is a string rather than an array. The core page post type is also singular. Here’s the fixed autocomplete form option:
Kind regards,
Alex
Thanks Alex, very helpful as ever.
I knew it would be something like that; annoyed with myself for not finding the alternative approach simply by looking at an existing widget! I was attempting to use modify_form because the category terms were not available when initialising the form fields in the constructor (too early perhaps?). get_widget_form is all I needed (without modify_form) as the terms are available at that point.
The restriction and suggestion would be a useful addition to the docs. I notice the ‘Creating a Widget‘ page demonstrates initialising the form fields in the constructor so it might be worth including a reference to get_widget_form there too.
Many thanks for correcting those other errors – above and beyond!
Hi C,
I’m glad that helped. This was definitely on us. I’ll submit a fix for this now.
Please feel free to open a new thread if anything else comes up.
Kind regards,
Alex
Hi Alex,
I’ve just spotted where I got that autocomplete code from in case you want to update that too: https://siteorigin.com/docs/widgets-bundle/form-building/form-fields/#heading-autocomplete.
Thanks
Hi,
Ah! Thanks for letting me know. I’ll submit a fix for that shortly.
Kind regards,
Alex