2

I have a project to QA all of our open webforms. We have about two screens (using the default pager) of open webforms.

The simple-but-hard way is to copy each link, but I wonder if there is an easier way. Can I programmatically pull up the path for all open webforms? Or is there a module?

I looked at building a view of webforms, but there was only an option to create a view of webform submissions, not of webforms themselves.

3
+50

You can do it in a custom module using entity.query service

$query = $this->entityTypeManager()->getStorage('webform')->getQuery();
$webform_ids = $query->condition('status', 'open')->execute();

$webforms = Webform::loadMultiple($webform_ids);
$webform_urls = [];
foreach($webforms as $webform){
  $webform_urls[] = $webform->toUrl()->setAbsolute()->toString();
}

Here is a demo module that uses entity.query in a controller to output those path as links with title as the title of each webform.

4
  • I've never had someone write a module based on my question! Thanks : D – user1359 May 15 '19 at 15:09
  • I've started a bounty so I can reward you for your above-and-beyond effort : ) – user1359 May 15 '19 at 15:10
  • 1
    Its a nice gesture, thanks. Drupal has always been helpful to me, just trying to give back as much as I can. – GiorgosK May 15 '19 at 15:16
  • I meant the Drupal community. – GiorgosK May 16 '19 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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