Problem/Motivation

Currently, it's not possible to enforce unique values for select components as it is with other components, such as email. For example, with the email component, it's possible to restrict submissions such that a single e-mail address can only be submitted once for a given webform. This issue proposes extending the select component to support the same functionality so that once a select option has been submitted, it is no longer available for future submissions.

Proposed resolution

  • Add a 'Unique' checkbox as an option on the 'select' component's edit page
  • Extend _webform_render_select() to run submissions through webform_validate_unique() if unique is selected for the component
  • Extend _webform_render_select() to remove previously submitted options from the options array if unique is select for the component

Remaining tasks

Need to submit patch

User interface changes

'Unique' checkbox is added as an option for the 'select' component on the component's edit page.

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chris Burge created an issue. See original summary.

Chris Burge’s picture

Liam Morland’s picture

Chris Matthews’s picture

Issue summary: View changes

The two year old patch in #2 still applies cleanly to the latest 7.x-4.x-dev and would be great to see this patch committed.

aaldayel’s picture

Patch in #2 works for me too.

Chris Burge’s picture

@Chris Matthews, @aaldayel - Thanks for testing out this patch. Setting the issue status to RTBC will help move it along.

Liam Morland’s picture

Status: Needs review » Needs work

Thanks for the patch.

Please use a Boolean instead of integer for the value. Add @todo next to the reference to #1077532: Implement "Disabled"-functionality for "Select options" also.

What happens if there are no options left and the field is mandatory?

This should have tests.