Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Darren Eccles 59 posts 298 karma points
    Jul 23, 2019 @ 15:10
    Darren Eccles
    0

    Umbraco 7 Form conditions not working

    I've got a umbraco 7.4.3 site using umbraco forms 4.4.2

    When I go to add conditions they don't work, for example

    1. I'll add a form element Q1 with Yes and No (multiple choice)
    2. I'll add a second form element Q2 (textbox) with a condition Show if Q1 is No

    Initially it hides the field, but when I select No, it doesn't do anything (I'm expecting to show Q2 when I select No), however in my console log I can see it showing and hiding.

    I have all my JavaScript files setup correctly, unobtrusive works with the mandatory fields.

    For some reason the following line is not updating client side:

    bool hidden = f.HasCondition && f.ConditionActionType == FieldConditionActionType.Show;
    

    I'm running out of ideas, I've been outputting info to the console log from App_Plugins/UmbracoForms/Assests/umbracoforms-conditions.js

    I've also made sure that all fields are mandatory, have default values etc...

    I've also looked at the google result for condition not working.

    Any help would be much appreciated

    Thanks

  • Darren Eccles 59 posts 298 karma points
    Jul 24, 2019 @ 09:10
    Darren Eccles
    100

    Hi all,

    Found the problem, nothing to do with the line of code above, the javascript conditional code was targeting the wrong div, see below:

    App_Plugins/UmbracoForms/Assets/umbracoforms-conditions.js

    Change:

    for (fieldId in fieldConditions) {
             handleCondition($("#" + fieldId).closest(".contourField"), fieldId, fieldConditions[fieldId], "Field");
        }
    

    To:

    for (fieldId in fieldConditions) {
            handleCondition($("#" + fieldId).closest(".form-group"), fieldId, fieldConditions[fieldId], "Field");
        }
    

    All my div's in umbraco forms are wrapped with the class '.form-group', not '.countourField'.

    Hopefully this will help others out :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies