AnsweredAssumed Answered

How to reset aikau form field values?

Question asked by manav on Mar 1, 2017
Latest reply on Mar 28, 2017 by aviriel

var myForm = {
            name: "alfresco/forms/DynamicForm",
            config: {
              setValueTopic: "SET_FORM_VALUE",
              widgets: [
                {
                  name: "alfresco/forms/controls/TextBox",
                  config: {
                    name: "prop_1",
                    label: "Property 1"
                  }
                },
                {
                  name: "alfresco/forms/controls/TextBox",
                  config: {
                    name: "prop_2",
                    label: "Property 2"
                  }
                },
                {
                  name: "alfresco/forms/controls/DateTextBox",
                  config: {
                    name: "prop_3",
                    label: "Property 3 - date"
                  }
                },
              ],
              widgetsAdditionalButtons: [
                {
                  name: "alfresco/buttons/AlfButton",
                  config: {
                    updatePayload: false,
                    label: "Reset",
                    publishTopic: "RESET",
                    publishGlobal: true,
                    publishPayload:{ widgets:
                         [{
                         id: "RESET_FORM",
                         name: "alfresco/menus/AlfMenuBarItem",
                         config: {
                           label: "Reset Form",
                           publishTopic: "SET_FORM_VALUE",
                           publishPayload: {
                             prop_1: "",
                             prop_2: "",
                             prop_3: null
                           }
                         }
                       }]}
                  }
                }
              ],
                   
                    showOkButton : true,
                    okButtonLabel : "Save",
                    showCancelButton : false,
                    cancelButtonLabel : "Cancel",
                    setValueTopic : "RESET",
                    setValueTopicGlobalScope : true,

                    // Specify the TOPIC here
                    okButtonPublishTopic : "ALF_CRUD_CREATE",
                    okButtonPublishGlobal : true,
                    okButtonPublishPayload : {
                         // Specify the URL here to POST the data
                         url : "/sample/test",
                    }
                   
               }

           
          };

// Add the form and services to the JSON MODEL
model.jsonModel = {
     widgets : [ {
          id : "SET_PAGE_TITLE",
          name : "alfresco/header/SetTitle",
          config : {
               title : "Create Title"
          }
     }, myForm ],
     services : [ "alfresco/services/CrudService"

     ]
};

 

I found a link that how to reset a form 

Resetting form 

Clearing Aikau Form Fields 
but this does't working for me,

I don't know where i am wrong.

// Create the form here
var formValue = {
            text: "Some value"
          };

          var myForm = {
            name: "alfresco/forms/Form",
            config: {
              setValueTopic: "RESET",
              setValueTopicGlobalScope: true,
              okButtonPublishTopic: "MY_TOPIC",
              widgets: [
                {
                  name: "alfresco/forms/controls/TextBox",
                  config: {
                    fieldId: "FIELD1",
                    label: "A TextBox",
                    name: "text"
                  }
                }
              ],
              widgetsAdditionalButtons: [
                {
                  name: "alfresco/buttons/AlfButton",
                  config: {
                    updatePayload: false,
                    label: "Reset",
                    publishTopic: "RESET",
                    publishGlobal: true,
                    publishPayload: formValue
                  }
                }
              ],
              value: formValue
            }
          };

// Add the form and services to the JSON MODEL
model.jsonModel = {
     widgets : [ {
          id : "SET_PAGE_TITLE",
          name : "alfresco/header/SetTitle",
          config : {
               title : "Create Title"
          }
     }, myForm ]
};

 

 

While clicking on reset button it is not clearing form field values.
please help.

Outcomes