Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Function parameter value from view js file is not getting invoked in controller function

Hi ,

I am trying to create form in SAPUI5 using sap.ui.layout.form.Form and am trying to reuse the code for generating same textfield many times. In order to do that I placed the code in a function in controller js file and When I am trying to pass a value from function in view js file to function in controller js file , it is not getting passed properly ie function is getting called but not the values.

Below is the code ,

//function in the controller js file

textField: function (labeltext,placeholder){

  var formElement = new sap.ui.layout.form.FormElement({

  label : new sap.ui.commons.Label({

text : this.labeltext    // passed text from view js is not getting here


  fields : [ new sap.ui.commons.TextField({

  required : true,

  layoutData : new sap.ui.layout.form.GridElementData({

  hCells : "3"


  placeholder : this.placeholder   // passed text from view js is not getting here

  }) ]


  return formElement;


// function in the view js file

  createContent : function(oController) {

  var oLayout2 = new sap.ui.layout.form.GridLayout("L2");

  var oForm2 = new sap.ui.layout.form.Form("F2", {

  title : new sap.ui.core.Title({

  text : "Employee Registration Form",

  tooltip : "Register here"


  editable : true,

  layout : oLayout2,

  formContainers : [ new sap.ui.layout.form.FormContainer("C2", {

  formElements : [


  oController.textField("Employee Name","Please enter ur name"), // calling function textField here


  }) ]




output :

Please guide me in this.

Former Member replied

Hi Venkatesh,

did you try without putting "this." before the variable?



1 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question