At one time or another, most Drupal developers have worked on a site with one or more Webforms that used a select list that pertained to some other entity on the site (such as a store location, law firm practice area, etc). And especially on sites with multiple forms, site administrators sometimes forget to update one of the lists.

The Webform Options by Bundle module fixes that for you. Webform has an feature on select lists for you to populate the options from a pre-built list such as countries or days of the week. This module uses a hook in Webform to let you populate the options with the labels of your entities. (Just to be clear, nodes are also entities. "Content Types" are bundles for the Node entity type. "Title" is the "label" for a Node entity.)

We've tagged a release as 7.x-1.0-rc1. You can download an archive from Github. (Yes, it's also available on Drupal.org - but sandboxes don't allow releases).

After downloading and installing the module, you first need to tell it what bundles to expose to Webform. This is very important. You do not want to use a bundle that has thousands of nodes. That would not be a good idea. So don't be that guy that tries to add 1,000,000 Article nodes to a select list.

Once you've done that, you can setup a Webform with a select list. All you have to do is tell it which bundle you want to use. For example, if you had your store locations as "Location" nodes, you'd select "Node: Location".

By the way, because the module populates the list using EntityFieldQuery and checking user access to each entity, your users will only see the entities that they have permission to view when they go to fill out the form.

If you liked this post, you should share it...

StumbleUpon icon
LinkedIn icon
Google icon
Reddit icon

Comments

Very cool. Is it possible to make the visibility permission optional?

Also, you should definitely submit the project for review so it can have full releases

I assume you're referring to whether or not users can see the options? That's based on whatever access callbacks are available through the entities and what permissions are set. I guess I can see a use case for allowing administrators to check a box to say "override access restrictions on X". I'll mull that one over a bit.

As for the project review, I currently have a pending application. It's been marked as RTBC for over a month now, and the last real feedback I got for it (other than the "I see no blocker issues" on the RTBC comment) was December 20, 2013. The current pending project application is my third. First one seems to have disappeared, second one was closed because someone with full project access created a similar module after the project application had started. I've pretty much given up.

I was referring to being able to override the visibility permissions based on your comment : "By the way, because the module populates the list using EntityFieldQuery and checking user access to each entity, your users will only see the entities that they have permission to view when they go to fill out the form."

With your application marked RTBC, I'm not sure what else to do to help push it forward. Perhaps try bugging someone in IRC or come find me at DrupalCon Austin and I'll help you track someone down. You might also want to try creating an application with this module - since it doesn't depend on a 3rd party service, its easier for someone to test/review it. Once you have project maintainer permissions, you should be able to make any of your sandbox projects full projects if you want.

Add comment

Stay updated!