Skip to Content

how can I get the value from the form which is written in controller?

In controller i have written a simple form. on click of a button this form will appear. I want to know how to take its value if i enter some data in the field without using id.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Apr 21, 2017 at 07:18 AM

    Instead of getting values by element ID's we can get through model.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 21, 2017 at 07:24 AM


    You need to use model for this to get any controls property value ..

    If you don't want to use the id of the form than attach the model with a model name to the view or page which contains your simple form

    var model = new sap.ui.model.json.JSONModel()




    1. <f:SimpleForm
    2. minWidth="1024"
    3. maxContainerCols="2"
    4. editable="false"
    5. layout="ResponsiveGridLayout"
    6. title="Address"
    7. labelSpanL="3"
    8. labelSpanM="3"
    9. emptySpanL="4"
    10. emptySpanM="4"
    11. columnsL="1"
    12. columnsM="1">
    13. <f:content>
    14. <Label text="Name"/>
    15. <Input value="{formModel>SupplierName}"/>
    16. <Label text="Street/No."/>
    17. <Input value="{formModel>Street} {formModel>HouseNumber}"/>
    18. <Label text="ZIP Code/City"/>
    19. <Input value="{formModel>ZIPCode} {formModel>City}"/>
    20. <Label text="Country"/>
    21. <Input value="{formModel>Country}"/>
    22. </f:content>
    23. </f:SimpleForm>

    Now on Button press event you can get the data of the model attached


    var data = this.getView().getModel("formModel").getData() // data contains the values you enter in the input fields above




    Add comment
    10|10000 characters needed characters exceeded

  • Aug 17, 2017 at 09:46 AM

    Any data from view to controller can be linked using data models. On binding, data typed on view will be instantly available in the models, which are accessible in controller.

    Element iD is also another way to get the data entered by user in view.

    SAP recommends usage of model binding to transfer data between views and controller.



    Add comment
    10|10000 characters needed characters exceeded