2
1
0

I am having 100 fields in a form and i need to clear all the field values in a form on page change.

How will i clear all the field values in a single shot ? Is there any method to do the same?

Kindly help to assists on this.

Thanks.

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi Vinodhini,

      To access all of the children of an item in Maestro. You can use the Util.sendAll method.

      You can look this up in the maestro API reference page.

      Util.sendAll(Form.view, function(item){
         if (data[item.id] !== undefined) data[item.id] = "";
      }, false, true)

      The first parameter is the item to get all the sub items from. In the case above the root form item.

      The second parameter is the handler, used to perform something on each item.

      The third is a flag for children only (Do not apply the handler to the item itself, only its children, so wont go to Form.view)

      The fourth is a flag that will go into the forms dialog and modal page items if the Form.view item is sent through.


        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Vinodhini, I had a bit of play with this myself and come up with the code bellow. You need to have all fields to be cleared under the same container/parent. Note that any fields under the same parent will be cleared.

        I wonder what the best practice here would be...

        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] = "";
        });

        cheers, Miro

          CommentAdd your comment...