Great Drupal Module by the way - awesome in fact.

I have a need to check a webform entry (postcode in my case) against a list of values in a list. I am currently doing this by checking the postcode with an OR operator 300x. Needless to say, this was a chore to enter and I could only do it in a timely fashion by editing the backend database and not through the UX. And I suspect it may be slower for the system to process (as 300 separate OR IF's)

Is it possible to have a new operator "Is In List" and provide a comma separated number of values (postcodes in my case) ? And ideally, make the field of values able to accept a large number of values (300 in my case). Or be able to check with a SQL query against a number of values in a table ?

This would be a real value add to the list of operators in my humble opinion.

Many Thanks.....

dp

Comments

dpdpkpcom created an issue.

Liam Morland’s picture

If you just need to validate that the value is in a given list and reject the form submission if it is not, you could use the webform_validation module's regex validator.

dpdpkpcom’s picture

Hi there

Thanks for the suggestion.

Form-validation takes care of incorrectly entered postcodes using regex.

Unfortunately though, I need this scenario :-

If the user-submitted postcode is on list A of postcodes, then set a hidden field in the form to X
If the user-submitted postcode is on list B of postcodes, then set the same hidden field in the form to Y
If the user-submitted postcode is on list C of postcodes, then set the same hidden field in the form to Z
etc...
etc....

And then when the form is submitted, the user is redirected to a page based on which area their postcode is in.

So, this "is in list" operator would be super helpful. I have it working but with 300 entries in the 3 relevant webform tables (in the database), which I suspect is not very efficient. It works fine as is, but I suspect when the website is advertised to the public, the server may be more loaded than were it not for the "is in list" operator.

Thanks very much for the suggestion though !!!!

:-)

dp

Liam Morland’s picture

Yes, I can see that would be useful. Really, validators and conditional should be related since they both are taking actions based on a test of a property of the input. If your form could be at all busy, load testing will be essential. Or write the patch needed to implement what you need.

dpdpkpcom’s picture

Totally agree re load testing - and I would write the patch but sadly, it is beyond my skillset.

I'll live in hope that some php whizz can come to the rescue ! :-) It definitely would add value to webforms as a module.

Thanks for the reply though!!

:-)

dp