1
0
-1

I have attempted to use Util.descendents and iterate through the children.value and setting to blank to no avail.

var fields = Util.descendants(item.$$parent.$$parent.$$parent)
for(var i = 0; i < fields.length; i++) {
  fields[i].value = "";
}

(The item in question is a button in a dialog)

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      The code needs to be changed to the following:

      var fields = Util.descendants(item.$$parent.$$parent.$$parent)
      for(var i = 0; i < fields.length; i++) {
        data[fields[i].id] = "";
      }
      1. Albert Hyde

        Hey Dave, this seems to be clearing the xml field as well, like you have ticked dont include in submission data. So if a user changes their mind and re-inputs data into the block, the data isn't saved and won't show on receipt. Any idea's around avoiding that?


        Just updating to say I found a solution here: How to clear the field values?

        Namely Miro's answer 

        var parentItem = Form.getItemFromPath("data.about_you"); // replace "data.about_you" with the id of your container where the fields to be cleared are
        var viewArrayChildrenToClear = Util.descendants( parentItem, false);
        angular.forEach(viewArrayChildrenToClear, function(value, key) {
          if( data[value.id] !== undefined ) data[value.id] = "";
        });


        Cleared the value and not the field so you can use it and still save the form

      CommentAdd your comment...