cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Render input fields on SimpleForm dynamically, loop on input field

jmandap
Explorer
0 Likes
4,316

Hi Experts,


I am having trouble on rendering question list data with yes or no radio field or switch field on my Form, data are coming from OData service. So the input fields that I need are in the service, my problem is how can I render it on simpleForm, other personal information are manually added on simpleForm , below the form I need to render the questions, but the problem is I don't know how to loop it, I tried using List but it affects the responsiveness and layout of the form.


Here is the form:
The blue box indicates the manually added input fields for personal data.
The yellow box is a sample question that I manually added, this is my problem, I cannot loop it with the same format of the form.
The red box is a sample, I tried using List to loop the questions, but as you can see it has a different rendering or layout.


I am a newbie of using SAPUI5 please help me.
Any possible solution would be accepted gratefully.
Thanks & Regards,
Jocel Mandap
View Entire Topic
0 Likes

Also, if you want to dynamically add content - you can do that in your view controller.

I tried using the below code in my dev space, and it adds with proper alignment.

You will get more flexibility with your data by doing this programmatically.

var oForm = this.getView().byId('<Your_Form_ID>');
         
  for (let index = 0; index < arr.length; index++) {
  oForm.addContent( new sap.m.Label({ text: arr[index] }) );
  oForm.addContent( new sap.m.Input({ type: sap.m.InputType.Text, placeHolder: "Some Text" }) );
}