[development] How to pass an email address vom cck to a webform

Steven Jones steven.jones at computerminds.co.uk
Tue Oct 6 07:08:00 UTC 2009


We have done exactly this for a client a couple of weeks ago, you can
do it (fairly nicely) by following the steps below:

1. Set up a link somehow (either CCK formatter or theme layer) on your
CCK node that links to your webform, but includes an additional GET
parameter, cck_id or similar. So users visit the webform by going to
/node/123?cck_id=456
2. Pop a hidden form element on the first page of the webform, and set
up its default value parameter to grab the cck_id from the
querystring.
3. Write yourself a custom submit handler on the webform that takes
the value of the hidden field and loads the node, gets the email
address etc. This submit handler gets run in the middle of the webform
execution so you can change the email address of where submissions can
be sent.
4. Write this up as a documentation page or similar :-)

Tips:
For 3. if you find the bit of code that runs the custom submission
handlers for a webform, you can write your code directly into that
file, tweak it until it works then just undo all your changes and
paste the code into the box on the webform edit screen.
Use devel or similar to log the emails instead of sending them.

Hope that helps.

Regards
Steven Jones
ComputerMinds ltd - Perfect Drupal Websites

Phone : 024 7666 7277
Mobile : 07702 131 576
Twitter : darthsteven
http://www.computerminds.co.uk



2009/10/5 Ernst Plüss <ernst.pluess at gmail.com>:
> Hi
>
> On our web site we have a big number of cck nodes which do describes
> different classes. The students should get a chance to subscribe to a class
> by filling in a webform.
>
> There are a few different cck node types and a big number of cck nodes. But
> we'd like to use only one webform (which is a node).
>
> My question is: The CCK nodes do contain an email address. The webform
> should somehow get the email address of the node which linked to it (via
> node reference?) and send the email to this address. How can we do this.
>
> I spend several hours in searching the web and drupal.org without finding a
> usefull answer. I would be very happy to get some usefull information on
> this topic.
>
> Thanks a lot.
> Ernst
>
>
>
>
>


More information about the development mailing list