cancel
Showing results for 
Search instead for 
Did you mean: 

how to make searchfield as mandatory in formelement

Former Member
0 Kudos

We need to make the searchfield label as mandatory  in a formelement.

GIven below is the code we have used. but not working.

new sap.ui.layout.form.FormElement({fields: [oSearch = new sap.ui.commons.SearchField("sf_srvcRecipient",{       
        value: "",
        enableListSuggest: false,
        layoutData: new sap.ui.layout.form.GridElementData({hCells: "5"})}
       )],
       label: new sap.ui.commons.Label("lb_srvcRecipient",{
        required: true, text: "Service Recipient", labelFor: oSearch
        })
      }),

Accepted Solutions (0)

Answers (2)

Answers (2)

SandipAgarwalla
Active Contributor
0 Kudos

apart from setting required s true, you need to bind the field to a type system or do a manual validation.

Former Member
0 Kudos

hi sandeep,

Kindly share the code.

Former Member
0 Kudos

Saket,

Can you please let me know if and how were you able to achieve this. I have the exact same requirement.

Thanks in advance for your help.

Vivek

former_member182372
Active Contributor
0 Kudos

new sap.ui.layout.form.FormElement({fields: [oSearch = new sap.ui.commons.SearchField("sf_srvcRecipient",{   

required : true,  

        value: "",

        enableListSuggest: false,

        layoutData: new sap.ui.layout.form.GridElementData({hCells: "5"})}

       )],

       label: new sap.ui.commons.Label("lb_srvcRecipient",{

        required: true, text: "Service Recipient", labelFor: oSearch

        })

      }),

Former Member
0 Kudos

Hi Maksim,

I put the required : true , but this didnt work. Kindly advise further