Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DanChadwick’s picture

Status: Active » Fixed

Your picture shows your components, not your conditionals.

You have more than one conditional action that is set to "is shown" or "isn't shown". You can't have more than one rule controling whether a component is or isn't shown.

Note that the absence of being shown is hidden and vice-versa.

Restructure your logic so that one rule (considting of one or more conditions, joined by AND or OR) -- and only one rule -- controlls the showing of the component.

themic8’s picture

Yes, I understand why I am getting this error.

I am interested to know why it decided to only allow one rule controlling whether a component is or isn't shown.

Webform conditionals allowed this, but not the new integration into the webform.

DanChadwick’s picture

TLDR: previously conditionals stored hidden data, requiring complex or impossible rules and leading to inconsistent and incorrect submissions and unintended emails.

For background, read the long issue about hidden values should be empty.

themic8’s picture

Dan,

Thanks for the follow up. I understand now.

Jason Wells’s picture

I'm experiencing a similar issue, and understand the reasoning you have described above, but just wondering if I then need to restructure my form?

For context, I have a registration form for participants (see: http://www.surfershealing.org/registration/lake-worth-fl-wait-list) and after they fill out the necessary fields they can select from a drop down menu the number of additional participants they would like to add. I have a conditional that hides the 3 additional fieldsets on load and depending on the selection, will then show the fieldsets required.

So selecting "1" will display additional fieldset (A), selecting "2" will display fieldset (A) and (B), and selecting "3" will display fieldset (A), (B) and (C)

conditionals_add-participants

DanChadwick’s picture

#5. Yes, you need to redo your logic. You can probably simply it. Webform now considers a hidden component as having an empty value, and does so the instant it become hidden.

Status: Fixed » Closed (fixed)

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

StephanTeo’s picture

Hello Jason and Dan. I am hoping you can help me as I have exactly the same problem you are having. Basically, I have a select which allows a user to select how many more participants to show. This will then show additional fieldsets asking for each participants information.

Jason, I can see you've got this going on your webform, would you mind sharing how your form is structured, as well as how you solved the webform conditionals by re-structuring your form/logic?

Any help appreciated.

Sincerely
Stephan

DanChadwick’s picture

Selects can not have relative operations (greater than, less than, etc).

IF #extras IS GREATER-THAN-OR-EQUAL 1 THEN SHOW Fieldset 1 with extra stuff.
IF #extras IS GREATER-THAN-OR-EQUAL 2 THEN SHOW Fieldset 2 with extra stuff.
etc.

tclnj’s picture

Issue summary: View changes
FileSize
107.98 KB

Ok, this new restriction for conditionals is making my life a bit difficult... and I'm at a loss as to how to resolve the issue (other than reverting back to an older version of Webform).

I have forms where there are multiple criteria of the form IF (a AND b) OR (a AND c) THEN show d.

Previously, this was accommodated easily by separate conditions with the same target -
IF a AND b THEN show d
IF a AND c THEN show d

Like this -
How?

Mixed AND and OR operators does not seem possible, so I'm at a loss as to how to consolidate these into a single conditional.

Thoughts?

DanChadwick’s picture

It's ugly, but could work for you:

Put d in fieldset super-d.
If a then SHOW super-d.
if (b or c) then SHOW d.
Hide the visual consequences of super-d's fieldset with CSS.

StephanTeo’s picture

Hello Dan, sorry for the delayed response - had to work on something else before I got back to this task. Unfortunately I still cannot get this webform to work showing/hiding multiple FIELDSETS based on the number of applicants they choose.

The STRUCTURE of the webform (parent/child relationships) work along with the CONDITIONALS (show/hide) - and I seem to be missing something still.

I've created a stacked/grouped webform structure which looks like this:

Webform Structure

And the associated conditionals look like this:

Conditionals

This seems to do the trick in terms of SHOWING/HIDING the relevant fieldsets, however the hidden FIELDS are still enforcing their form validation rules for being MANDATORY - and thus cannot continue.

This is what I get if one or more fields are HIDDEN via Conditions and I try to CONTINUE:

Error

Can you please assist?

Regards
ST

DanChadwick’s picture

I bet you are using the select or other module. If so, update to the latest and your problem will be solved.

StephanTeo’s picture

Hi Dan, no - not using https://www.drupal.org/project/select_or_other.

Is how I've structured the FORM with the stacked FIELDSETS how you would solve this problem?

I'm still not sure what I'm doing wrong?

Sincerely
ST

DanChadwick’s picture

Status: Closed (fixed) » Active

This is not how I would do it, but what you did should still work. Is there some other module that you are using that is causing this? Have you tried it with a clean install and a simpler test case?

I would not nest the fieldsets and:

if TEST >= 1 then show Fieldset 1
if TEST >= 2 then show Fieldset 2

I recently added the relative operators to select components. It uses the order in the option list, not the alphabetical or numeric order of the keys.

DanChadwick’s picture

Status: Active » Postponed (maintainer needs more info)

I just tried to reproduce your validation issue and cannot. I tried both the next and the unnested variations.

The symptom you have is EXACTLY what happens with select or other (before the latest version). It adds additional fields to the form and uses the attributes of the select element, including the HTML5 attribute. Webform removes this attribute when the field or its parent is hidden and restore is when shown. Because webform doesn't know about the additional fields, you get a hidden required field, which gives the behavior you see (although I've seen the balloon at the top left, rather than bottom left of the window).

I think you'll need to debug to see what field is hidden and required.

DanChadwick’s picture

Status: Postponed (maintainer needs more info) » Fixed

Closing this, since we this issue #12-16 is not related to the original issue. Please reopen if you are still having trouble, with detailed instructions to reproduce the issue with a clean installation and minimal modules.

Status: Fixed » Closed (fixed)

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

Sohal Khatwani’s picture

FileSize
100.21 KB

Firstly Dan thanks for maintaining the great webform module. I have used it a fair bit and am still learning the possibilities. I have not got stuck with this issue on a webform I am building for registering a pet with an organisation. Essentially, a user has the option to register one, two or three animals in the same form. I created three different fieldsets for each of the pets. Each have their own fields which are quite similar. We would like a user to come and choose how many pets they want to register. If they choose one then only one fieldset should show, two then fieldset one and two should show, three then fieldset one,two and three should show. However, when I go to set this up with the conditionals I get the error More than one conditional hides or shows component "Animal Two".

Is this a bug or would it require me to change the format of the form. If I need to change it can you offer any advice as the current process already seems logical to me but does not work with webform.

I am using the latest version of select or other and webform 7.x-4.12.

Thanks.