I'm having trouble getting conditional fields to work with a custom form theme in Umbraco 10. If I render the scripts using the default theme the conditions work. i.e
The issue seems to be in my theme the formElementHtmlIdPrefix used in umbracoforms.js returns undefined compared to an empty string in the default, so it's looking for "undefinedxxxxxxx" in my theme rather than just "xxxxxxx".
Today we encountered the same problem where toggling Umbraco Forms fields using conditions didn't work. Umbraco 10, forms v10.2.2
What we found is that the "undefined" value of formElementHtmlIdPrefix can be solved by adding a data attribute "data-form-element-html-id-prefix" to the .umbraco-forms-form-config div in Script.cshtml in your forms theme.
You can create your own custom prefix as Model.FormElementHtmlIdPrefix by adding the Forms settings in appsettings.json like explained in the docs you linked to in your post.
I'm unsure if this is a workaround for a problem of our own creation, or if this is a bug in the default theme in Umbraco Forms. If anyone has a better solution I'm more than happy to hear it
Umbraco Forms conditions with custom theme
Hi,
I'm having trouble getting conditional fields to work with a custom form theme in Umbraco 10. If I render the scripts using the default theme the conditions work. i.e
Loading the theme scripts (which are the same as default) the conditions don't work:
The issue seems to be in my theme the formElementHtmlIdPrefix used in umbracoforms.js returns undefined compared to an empty string in the default, so it's looking for "undefinedxxxxxxx" in my theme rather than just "xxxxxxx".
The only reference to formElementHtmlIdPrefix I can find says it's set in appsettings.json https://docs.umbraco.com/v/10.x-lts/umbraco-forms/developer/configuration#formelementhtmlidprefix which I've tried setting, but that doesn't appear to be picked up by my theme or the bootstrap one.
Am I doing something wrong? Any ideas?
Thanks
Hi M,
Today we encountered the same problem where toggling Umbraco Forms fields using conditions didn't work. Umbraco 10, forms v10.2.2
What we found is that the "undefined" value of formElementHtmlIdPrefix can be solved by adding a data attribute "data-form-element-html-id-prefix" to the .umbraco-forms-form-config div in Script.cshtml in your forms theme.
This would result in the following:
You can create your own custom prefix as Model.FormElementHtmlIdPrefix by adding the Forms settings in appsettings.json like explained in the docs you linked to in your post.
I'm unsure if this is a workaround for a problem of our own creation, or if this is a bug in the default theme in Umbraco Forms. If anyone has a better solution I'm more than happy to hear it
Thank you so much <3
is working on a reply...