Limited Supply Options Lists in Webforms

2011-03-12

Jitesh Doshi

Limited Supply Options Lists in Webforms

How to create limited supply select options in Drupal webforms that remove options once used in a submission.

In Drupal webforms, often we come across situations where we have select component (displayed as select list, radio buttons or checkboxes) in a webform, but we don’t want multiple submissions to use the same options.

For example, when people are reserving seats for themselves using your webform, you don’t want two people to reserve the same seats. This means you want options in the select component to start disappearing from the webform display once they are used in a webform submission.

The module works by:

  1. Using hook_form_alter to add a checkbox to the webform component edit form
  2. Using hook_form_alter to alter every Drupal form derived from a webform node and look for select components
  3. Removing those options from them that have already been used in a previous submission

This module removes an option from a select list as soon as it is used once in a webform submission. Future enhancements could include specifying how many times each option can be used.