Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional field sets based on Drop Down values don't show. #207

Closed
NikRimington opened this issue Aug 20, 2019 · 6 comments
Closed

Conditional field sets based on Drop Down values don't show. #207

NikRimington opened this issue Aug 20, 2019 · 6 comments

Comments

@NikRimington
Copy link

NikRimington commented Aug 20, 2019

Umbraco Version: 7.15.1
Umbraco Forms Version: 7.1.1

Bug Description

A large form which has multiple conditional field sets based on a drop down isn't showing the conditional fields when the drop down value changes. This means that questions aren't showing to the front end user and, as some are mandatory, the form doesn't submit and doesn't show errors.

What I would expect to happen

I'd expect the conditional questions to show when the appropriate drop down option is selected.

Why does this occur

The error appears to be occuring in the conditional rule validation where values are retrieved and compared. When the JS code is retrieving the value for the drop down it is adding an extra space to the value it get's. As a result when performing it's rule check for conditional logic it is failing as "A string " does not equal "A string".


This item has been added to our backlog AB#2343

@nul800sebastiaan
Copy link
Member

Yikes, good find! So we'll need to figure out why it would add a space there at the end.. so weird. We'll have a look at it!

@NikRimington
Copy link
Author

Yep it's very odd, I couldn't figure out where the extra space comes from either, but it was visible in this function:

function evaluateRuleInstance(rule) {
    var value = values[rule.field],
    func = operators[rule.operator],
    result = value !== null && func(value, rule.value);
    // console.log(rule.field + ": " + value + " " + rule.operator + " " + rule.value + " = " + result + "\n");
    return result;
}

At this point, the value of value seems to have the extra space from what I could see. I tried tracing it back to see the source but could't find it.

@JonathonCove
Copy link

JonathonCove commented Apr 1, 2020

Hello @nul800sebastiaan

I have also encountered this issue. It can be fixed by adding a .trim() to the comparison in javascript. The below image should show what I mean.

image

Should I create a pull request for this change?

@umbrabot
Copy link

umbrabot commented Apr 3, 2021

Hiya @NikRimington,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant
This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@umbrabot umbrabot added the status/stale Marked as stale due to inactivity label Apr 3, 2021
@umbrabot umbrabot closed this as completed Apr 3, 2021
@number45
Copy link

@umbrabot still relevant
I've just encountered this bug in Umbraco 8.6.0 using Umbraco Forms 8.6.0.

It looks like it is the text of the select option (rather than value) that is used for comparison so if the text doesn't nudge up to the > and < of the html tags you end up with whitespace around it and the comparison fails.

This is what we had in our themes FieldType.DropDownList.cshtml files when showing the conditional was failing:

<option value="@pv.Value"
@if (Model.ContainsValue(pv.Value)) { <text> selected="selected" </text> }>
@pv.Value
</option>

Changing it so the entire thing is on one line fixes the issue.

<option value="@pv.Value" @if (Model.ContainsValue(pv.Value)){<text>selected="selected"</text>}>@pv.Value</option>

@AndyButland
Copy link

Resolved in the linked PR and due in 8.7.2,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants