I need a little help to create a php snippet.
I'm creating a webfrom for a university event, the applicants can choose 3 dates but max. 15 applicants for each.
The last field of it therefore is a selection field with the 3 dates, e.g. 'attandance_date'.
The organizers want to limit the number of submissions for each date to 15, then close the form for that date with a message like 'full house', whatever.

For the moment, as a temporary solution i managed it by creating 3 different forms on different links and used this snippet:
http://drupal.org/node/342896#comment-1952380
to limit the total number of submissions to 15. It would all be okay, but thus I inserted some text as markup in each form above the submit button 'you have chosen 30.07.2010 to attend the programme, thank you...etc.'. As it is 'markup' neither the organisers nor the applicants who receive confirmation emails after each submission seet the date at the bottom of the form data emailed to them.
Alternatively is there any module or way to set a customized email message? But it would be even simpler to set 'markup' field type to be email-able.
But most of all the long-term solution would be the to find the right tweak and work with 1 form only as described in the 1st paragraph.
Many cheers for any help.

Comments

quicksketch’s picture

I don't provide support on writing custom PHP code for Webform, though I'll leave this open to see if anyone else has any input.

tiwaz’s picture

Thanks anyway.
As to the 2nd part of my of post about including "markup" fields in results, forum posts suggest that normally i should just change this line in markup.inc:
function _webform_submission_display_markup($data, $component, $enabled = FALSE) {
the FALSE value to TRUE
tried it, no joy.
If it is a simple thing to get it to work (include markup fields in results) that wouldnt be considered serious php coding i'd be grateful if you or any1 gave me a hint for this.

vernond’s picture

@tiwaz - based on the snippet you referred to, you could create a node-specific webform.mail.tpl and add the extra text (event now over-subscribed... whatever) into the email by checking the following:

   if (empty($node->webform['roles'])) {
      // throw in extra text here
   }
tiwaz’s picture

@ vernond:
Thank you so much u gave me a hint how to fix another problem: to do away unnecessary things from the outgoing email message by modifying webform.mail.tpl.

As to the markpup fields, the solution i finally utilized was simpler than anything: I created an additional hidden field (which can be included in the email) and copied the entire content of the markup field into the hidden field so the text appears in the emails now as it should.

For the record, I didnt dare to live-test the new webform module beta for this ongoing project but took a look at it on another Drupal test-site of mine and the good news is that Webform 3.x is a lot more advanced and will be able to handle such extra validation tasks by default (e.g. limit submission numbers according to fields).

Cheers!

quicksketch’s picture

Status: Active » Fixed

Super, thanks vernond!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.