AnsweredAssumed Answered

Aikau Simple Form Example

Question asked by muralidharand on Mar 7, 2015
Latest reply on Mar 29, 2015 by satheeshkumar
Hi All,
I created a very simple aikau form example.

http://www.codingfreaks.net/2015/03/aikau-form-example-for-simple-student.html



/* Here is the code of  student-form.get.js   */

/*
This page is used to render a simple form and POST the data to repository,
to create a new student folder under Document Library.
The Student model in described here ……..
Import the student model as described here….
*/

/* get the current site */
var site = page.url.templateArgs.site;
//Read the node reference of Document Library
var alfDestination = null;
var result = remote.call("/slingshot/doclib/container/"+site+"/documentLibrary");
if (result.status.code == status.STATUS_OK)
{
   alfDestination = JSON.parse(result).container.nodeRef;
}

//Create the form control for the student
var studentFormWidget = [     
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "Student ID",
     name: "prop_student_StudentID"
      }
    },
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "First Name",
     name: "prop_student_firstName"
      }
    },
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "Last Name",
     name: "prop_student_lastName"    
      }
    },
    {
      name: "alfresco/forms/controls/DojoValidationTextBox",
      config: {
     label: "Email",
     name: "prop_student_email"
      }
    }
  ];  

 

//Create the form here
var form = {
   name: "alfresco/forms/Form",
   config: {
      showOkButton: true,
      okButtonLabel: "Save",  
      showCancelButton: false,
      cancelButtonLabel: "",
   //Specify the TOPIC here
      okButtonPublishTopic: "ALF_CRUD_CREATE",
      okButtonPublishGlobal: true,  
   okButtonPublishPayload: {
  //Specify the URL here to POST the data
        url: "api/type/student%3AstudentFolder/formprocessor",
  //To create the folder under document library, we need the documberLibrary nodeRer,So POST that too.
  alf_destination:alfDestination        
   },
     widgets: studentFormWidget
   }
};

//Add the form and services to the JSON MODEL
model.jsonModel = { widgets: [ form ],   services: ["alfresco/services/CrudService"] };





/* Details of   student-form.get.desc.xml   */
<webscript>
  <shortname>Student Form Example</shortname>
  <family>Aikau</family>
  <url>/studentForm</url>
</webscript>


/*   student-form.get.html.ftl   */
<@processJsonModel group="share"/>


Outcomes