I'd like to use the current open/closed status of a webform in a conditional on the webform-submission-information.html.twig. There is a "webform" variable available to use in the template_preprocess_webform_submission_information function, but all that seems to do is print a link to the webform. When I try to use the usual methods that I'd usually use on a webform object, I just get WSOD. Something tells me that variable isn't actually an object.

For example, perhaps I could get the webform id and use that to figure out the status of the webform...

$form = $vars['webform']['details']['nid']['#value'];

Also, is there a resource for figuring out the pathing to the API is for the Webform? The documentation exists on the Drupal site certainly, but it'd be a lot easier if there was some kind of resource that gave us the path to all these data endpoints. As it stands, even if I figured out the correct function for extracting the webform's ID, I wouldn't have any clue how to find the status (open/closed) endpoint. There are some old d7 articles and issues out there, but it'd be nice if we didn't have to rely on issues and, instead, if there was intuitive documentation.

1 Answer 1


Indeed, calling {{ webform }} inside webform-submission-information.html.twig only contains a link. But since you have the webform_submission you can get the webform and from there can call isOpen and isClosed.

<div class="current-webform-status">
  <b>{{ 'Current Webform status'|t }}:</b> {{ (webform_submission.getWebform.isOpen) ? 'Open'|t : 'Closed'|t }}


<div class="current-webform-status">
  <b>{{ 'Current Webform status'|t }}:</b>
  {% if webform_submission.getWebform.isOpen %}
    {{ 'Open'|t }}
  {% else %}
    {{ 'Closed'|t }}
  {% endif %}
  • Awesome! Thank you so much for this answer. I was trying to use webform.isOpen which I found from another question, but I guess that's only available on the root webform template. Is there any documentation that you know of on this and other Methods used in Drupal twig templates for accessing external or parent variables? The var dump and php storm don't seem to mention anything useful.
    – Loopy
    Sep 23, 2020 at 12:35
  • @Loopy – No, not that I know. I was finally also only dumping what I found inside the variables in template_preprocess_webform_submission_information to find this out.
    – leymannx
    Sep 23, 2020 at 13:47
  • Twig has a dump() function.
    – mbomb007
    Nov 9, 2023 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.