Webform has the ability to only allow "unique" values on a few fields, including textfields, emails, and numbers. This support should be added to the Form Builder integration.

Comments

gdunkle’s picture

StatusFileSize
new3.58 KB

Here is a start. This implements unique validation on textfield and email components.

fenstrat’s picture

Status: Active » Needs review
StatusFileSize
new3.57 KB

Attached patch adds the "unique" setting for email, number and textfield's.

  1. Added form_builder_webform_property_unique_form() at the top of form_builder_webform.components.inc, best spot I could find.
  2. Unsure what to use for '#weight' in form_builder_webform_property_unique_form() so have left it out. Without it it appears under "Required" as expected.
  3. I've added a '#description' as per webform. I've noticed other properties in form_builder don't have a description, is this intentional?
quicksketch’s picture

Hey @fenstrat! Thanks for the patches. I'm encountering a similar problem with the "private" option, which also needs to be available as a FAPI property for Form Builder to edit it. I'm going to take a crack at combining your patches here with the approach I've used in these issues:

#1729726: Webform "private" option does not load properly
#1730714: Allow "private" option to be editable in Form Builder

quicksketch’s picture

Hm, actually "unique" isn't a global property that is defined in hook_webform_component_info() like "private" is. Maybe your approach is more suitable for this situation, unless we want to make "unique" a global feature like "conditional" and "private". I'm not sure it applies to the majority of properties or not.

fenstrat’s picture

No worries @quicksketch. Yeah to be honest I'm actually not sure of the usefulness of the whole "unique" validation. Somehow it got enabled on an email component and so I went to turn it off in form builder only to find it wasn't possible, hence the patch in #2. I'd have to agree that it's not a global option, just the 3 component types, and while there is code repetition in #2 I think it's the best way forward (unless you see a need to extend the unique setting).

So in this case this is a webform only property, so the "webform_" prefixing idea in #1729726-1: Webform "private" option does not load properly shouldn't apply right?

torotil’s picture

Status: Needs review » Reviewed & tested by the community

The patch works quite fine for me on multiple sites. Setting this to RTBC.

David_Rothstein’s picture

I just posted a patch at #1662904: Allow unique validation on grid components to add a "unique" validation option for the Webform grid component, so here's a patch to add it to Form Builder too.

It can be considered a followup patch for this issue (depending on the fate of #1662904: Allow unique validation on grid components) so it shouldn't be committed now and doesn't interfere with the RTBC status of the patch above; that's why I gave it a "do-not-test" suffix.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @David_Rothstein! Committed finally.

David_Rothstein’s picture

Status: Fixed » Reviewed & tested by the community

I am sorry for cluttering this issue a bit with my "pre-commit followup", but see my comment above - #2 still needs to be committed also. It looks like only #7 was committed, so I'm setting this back to RTBC. Thanks!

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Doh, thanks @David_Rothstein! Committed and pushed to the 7.x branch.

Status: Fixed » Closed (fixed)

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