Webform select list - show usernames?

kamitchell - January 8, 2009 - 20:09

Hello,

Is it possible to have a select list on a webform showing all users within a role? I would like to do this to send out a form conditionally to the person selected from the list. Or is there any other module or way that I can do this?

Unfortunate

gforce301 - January 8, 2009 - 21:00

AFAIK webform does not hadle something like this by default. In theory you could write a field module for webform or a custom module that modifies the webform to get a list of users. The other way would be to custom code your own mail form. Unfortunately I have never come accross a module that does what you are asking.

There is one in CCK, but I

kamitchell - January 14, 2009 - 00:33

There is one in CCK, but I don't understand it enough to be able to use CCK as a simple webform

CCK and Webform are fundamentally different

gforce301 - January 14, 2009 - 01:06

A CCK form is for creating nodes. A webform is a node that (usually) sends an email on submission (but does not create a new node everytime it is submitted). Using CCK to create a mail form is possible. However, everytime someone submits the form you would get a node created (might not be desirable) and you would still have to create a mail handler in a module and use hook_nodeapi to send the mail when the node was inserted (probably not the best way to do this).

Basically you are trying to set the "To:" field of the webform based on the selection of a user to send it to. The problem is that webform does not have a mechanism for dynamically populated select lists. Some possible solutions:

  1. Code a field module for webform that would make a selector of users (this is not an easy task).
  2. Code a drupal module that performs a form_alter on a webform node to change an already exisiting select list's options to be a list of users (slightly easier).
  3. Code a drupal module that creates it's own form. This allows you to put whatever fields you want on the form and populate them with whatever you choose. This method bypasses webform altogether and means you will have to handle all aspects of the form submission including sending the email, validation and storing any information you want to store.
  4. Use javascript to change the options presented in an option select already on the webform or to change an email field on a webform into an option select.
 
 

Drupal is a registered trademark of Dries Buytaert.