- Issue created by @thecooltechguy
- Status changed to Postponed: needs info
over 1 year ago 9:37pm 19 July 2023 I am pasting my comment from SE:
Are there errors in browser console? What, technically, does "works" and "does not work" in this question? Can you be more precise about that aspect please?
There are no errors in the browser console.
By "works" and "does not work", I meant that the conditional behavior of the elements isn't working. For example, say that I make an element that is conditionally disabled when a checkbox is checked. When I view the webform in the View or Test pages, it works as expected -- when I check the checkbox, the element is disabled, and vice versa. However, when I embed the webform as described in my issue, this no longer works: if I check the checkbox, the element doesn't become disabled, etc.
This is an example of conditional logic that doesn't work for webform elements when rendered/embedded via Drupal.
Thanks for your help, and lmk if I can further clarify anything!
When embedding single-page forms using the render array approach explained above:
1. If I do #lazy => FALSE, conditional logic doesn't work
2. If I do #lazy => TRUE, conditional logic worksWhen embedding multi-page forms using the render array approach explained above:
1. If I do #lazy => FALSE, conditional logic doesn't work on any page
2. If I do #lazy => TRUE, conditional logic works ONLY on the first page. It does not work on any subsequent page.Side note:
I also noticed that there is no page refresh when going between pages in a webform embedded with a render array, unlike what happens in a block-embedded webform, where the page is refreshed when going between pages -- and conditional logic works in blocks.So I think that whether or not the page refreshes has something to do with whether or not the conditional logic works, etc. I'm not 100% sure on this, just a suspicion.
- Status changed to Active
over 1 year ago 5:47pm 20 July 2023 Hi! Just wanted to see if there are any solutions/possible workarounds for this issue, that I could try? thanks!
- π¨π΄Colombia Ozle BogotΓ‘
Hi @thecooltechguy,
I was able to replicate this problem and found that if you enable Ajax on your web form it works correctly:
without Ajax:
Using Ajax:
- πΊπΈUnited States alphex Atlanta, GA USA
I can verify that this problem exists ALSO on webforms that are loaded by 'webform reference' fields.
On a number of my sites, I have content management activities where admins will create a page, and place a paragraph type that allows them to select from a series of webforms, that get displayed ont he page ...
When built on a page that way, the conditional logic does not work.
It does work when we got to the "webform" "view" directly.
- Status changed to Closed: won't fix
6 months ago 9:34am 27 June 2024 - πΊπΈUnited States jrockowitz Brooklyn, NY
Your code is nesting a webform inside a form, and it won't work as expected.
If you place the webform via a controller, it will work as expected.