Copied to clipboard

Flag this post as spam?

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


  • Ben McKean 272 posts 549 karma points
    May 09, 2017 @ 14:01
    Ben McKean
    0

    Conditional logic not working v6.0

    I have a drop down and I want to show/hide a fieldset dependent on its value.

    I have set this up as follows:

    enter image description here

    When I view the form on the frontend I can see that there is "display:none" on that fieldset, which is correct but when I change the value of my dropdown to "New homes" it doesn't show it.

    The question and the fieldset are on the same page but I'd still expect it to work.

    Is this a bug?

    Thanks

    Ben

  • Ben McKean 272 posts 549 karma points
    May 09, 2017 @ 14:20
    Ben McKean
    0

    I've spotted the following hidden field on the form, not sure if this is right or not...:

    <input type="hidden" id="fsConditions_a70ab2ebde1449859f9f3fe08e7ff12a" value="{&quot;c7e39b79-f574-4817-cdf4-ddfe1d46205e&quot;:{&quot;id&quot;:&quot;00000000-0000-0000-0000-000000000000&quot;,&quot;actionType&quot;:&quot;Show&quot;,&quot;logicType&quot;:&quot;All&quot;,&quot;rules&quot;:[{&quot;id&quot;:&quot;00000000-0000-0000-0000-000000000000&quot;,&quot;fieldsetId&quot;:&quot;2f406ce7-9e60-4b0b-9312-6409495f752a&quot;,&quot;field&quot;:&quot;e9e1d29f-7159-43b3-e646-7419a6046248&quot;,&quot;operator&quot;:&quot;Is&quot;,&quot;value&quot;:&quot;New homes&quot;}]}}">
    
  • Ben McKean 272 posts 549 karma points
    May 09, 2017 @ 14:49
    Ben McKean
    0

    Issue created here, please vote up

    http://issues.umbraco.org/issue/CON-1347

  • Adam Strandberg 1 post 71 karma points
    May 09, 2017 @ 20:50
    Adam Strandberg
    0

    Same problem here. Tried with old and new Views files but no difference. Downgraded to 4.4.2 and it works fine.

  • Ben McKean 272 posts 549 karma points
    May 16, 2017 @ 15:28
    Ben McKean
    0

    I found the issue. The Partials\Forms\Form view needs to contain the surrounding <div class="countourPage"> for this to work.

    We'd removed it to style the form as we didn't think it'd actually be use for how Forms work as there are plenty of other ways of targeting the form....

  • Erik Foppen 20 posts 62 karma points
    Jun 07, 2017 @ 14:12
    Erik Foppen
    0

    Hi Ben,

    only adding a <div class="contourPage"> around the partials didn't fix the problem for me so I investigated a little further. This is my fix (will try to provide this fix asap to UmbracoForms):

    1. I didn't wrap the partials with the contourPage class
    2. in Views\Partials\Forms\Script.cshtml I changed the selector of the form:

      var contourFieldValues,
          recordValues = JSON.parse($("#values_" + formId).val()),
          fsConditions = JSON.parse($("#fsConditions_" + formId).val()),
          fieldConditions = JSON.parse($("#fieldConditions_" + formId).val()),
          form = $("#umbraco_form_" + formId); // this was #contour_form_
      
    3. also I changed the input selectors a bit:

          $("select", form).each(function () {
              contourFieldValues[$(this).attr("id")] = $("option[value='" + $(this).val() + "']", $(this)).text();
          });
      
      
      
      $("textarea", form).each(function () {
          contourFieldValues[$(this).attr("id")] = $(this).val();
      });
      
      
      $("input", form).each(function () {
      
    4. lastly, I made sure the id of the form was correct, in Views\Partials\Forms\Themes\default\Render.cshtml:

    <div id="umbraco_form_****Model.FormClientId">

    Hope this is also helpful to others!

    Erik

  • Matthew Kirschner 323 posts 611 karma points
    Jun 07, 2017 @ 14:41
    Matthew Kirschner
    0

    There's an existing issue regarding the use of class names in important Forms scripts. Comment and upvote here: http://issues.umbraco.org/issue/CON-1314

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Aug 29, 2017 @ 16:29
    Jon R. Humphrey
    0

    Just as a small addition, you might want to edit the ready function to follow the changes @Ben outlines:

            $(function () {
            //$(".contourPage input, .contourPage textarea, .contourPage select", form).change(function () {
            $("input, textarea, select", form).change(function () {
                PopulateFieldValues();
                CheckRules();
            });
    
            PopulateFieldValues();
            CheckRules();
        });
    

    And if you get the dreaded Uncaught TypeError: umbracoForms.conditions.handle is not a function error change the CheckRules method to the following:

    function CheckRules() {
            //umbracoForms.conditions.handle({ <- Doesn't exist in code
            umbracoForms.conditions({
                fsConditions: fsConditions,
                fieldConditions: fieldConditions,
                values: contourFieldValues
            });
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft