(title may need to be tweaked but this is the gist of it)

I've built a multiple step form, with No AJAX. I need this form to be on a node, so I didn't have it set to a URL.
I place the block in the content area of the page, and go to the page. The form ( 4 steps ) works as it should.

Because I don't want this form to be on _every_ page, I set the block visibility for pages to be /manage/hello ( the actual page I want to have the form on ) I clear the cache and then visit the page. The form is there. I fill out the first step and click next and about 50% of the time it goes to the next step, and 50% of the time the form completely disappears. If it makes it to step 2, I fill out info and click next and 100% of the time it disappears.

At one point I was doing a drush cr after getting to each new step and was successful in getting it to complete, so I thought it was caching related. But as noted above if there was not visibility set for pages ( form was on all pages ) it worked fine.

On a whim I set the visibility to not the alias of /manage/hello but to /node/232 ( the actual nid of the page ) and all four steps work as it should.

It seems that the url is changing ( though in the url bar it stays the same as expected ) The Track wizard progress in the URL by ? setting for the form is set to None.

Comments

StevenPatz created an issue. See original summary.

jrockowitz’s picture

Status: Active » Postponed (maintainer needs more info)

I am not able to replicate this issue using the 'Example: Wizard' provide by the webform_examples.module.

I tested placing the 'Example: Wizard' webform as a block on a new node using the node's system path (/node/NID) and its URL alias. The webform block appeared and worked as expected when paging between wizard pages as an anonymous user using both the system path and URL alias.

When AJAX is disabled the URL in the browser's address bar is what is being processed and a block's 'page visibility' handles both system page and URL path based on the displayed URL.

On Drupal Slack, I said you were able to reproduce this issue via simplytest.me.

Was there something special about the webform that you used?

stevenpatz’s picture

No, it's a pretty standard webform, just 4 steps, some dropdowns, some textfields, some static text. I've just got my stuff to our next environment and will do some testing there in case it was a local issue. I'll update when I know more. Thanks for the quick turn around.

stevenpatz’s picture

Actually re-reading your comment....did you try with _just_ the system alias?

jrockowitz’s picture

I tested the system path and URL alias.

hongpong’s picture

I am having a similar issue where the anonymous visitor cannot see webform as block (a single-step form, not a multi-step form).

I put the forms in two different ways, using display_suite and twig tweak modules, with a statement like:
{{ drupal_entity('webform','donate_to_our_collections_form') }}
inside of the twig file for the layout of the paragraph.
And also using the "block field" module and creating a block with a webform reference as a field.

It works fine for the root user. It does not work fine for a site editor user who should have permissions to see this. The Ajax setting does not make a difference one way or another.

In the past I had some issues with forms and caching problems, I was able to get around them by setting URL-specific cache tags in the preprocess block theme hook. Dumping the preprocess hook is the next thing I would try. I will update here if I can find anything further.

jrockowitz’s picture

There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton

For the Twig Tweak issue see #2998110: Webforms disappear for anonymous users after webform update

For the block field issue see #2999660: Block content cache is not merged into the field's build array

hongpong’s picture

Thanks jrockowitz that worked perfectly for me!

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)