Reputation: 123
Im currently learning SAPUI5 with the following book. In the book there is a code listing where a simple form in XML should be created. I copied the source code from the listing but it is not working. So here is the original listing for the view from the book:
<mvc:View controllerName="Formular.controller.View1"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc" displayBlock="true"
xmlns="sap.m"
xmlns:FormularNamensraum="sap.ui.layout.form">
<App>
<pages>
<Page title="{i18n>title}">
<content>
<FormularNamensraum:FormElement label="Nachname" visible="true">
<FormularNamensraum:fields>
<Input/>
</FormularNamensraum:fields>
</FormularNamensraum:FormElement>
</content>
</Page>
</pages>
</App>
</mvc:View>
In the SAP WebIDE the following warning in line 10 is shown: warning: Semantic Error: SAPUI5: The candidate for aggregation node sap.m.Page is incorrect. Please enter a candidate of type sap.ui.core.Control.
So what did I do till now to solve the problem? I looked up if there are similiar cases when a form is created and this warning appears, no results. I checked the SAP Forums and the Documentation in order to find the mistake e.g. an old libary or a change in a libary, no results.
So I would be thankful if someone could explain to me what the mistake here is, since this example seemed to work in previous versions of SAPUI5. Thank you for any help and your time helping me.
Upvotes: 0
Views: 1276
Reputation: 534
You're missing a FormContainer
which represents a group inside the Form and work as Containers with the content of the form.
A FormContainer
consists of FormElements
. The rendering of the FormContainer
is done by the FormLayout
assigned to the Form.
Finally, FormElements
represent rows inside a FormContainer
.
Following the correct structure, your code should look like this:
<mvc:View controllerName="Formular.controller.View1"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
xmlns="sap.m"
xmlns:FormularNamensraum="sap.ui.layout.form">
<App>
<pages>
<Page title="{i18n>title}">
<content>
<FormularNamensraum:Form editable="true" id="oForm">
<FormularNamensraum:formContainers>
<FormularNamensraum:FormContainer title="Title" id="oContainer">
<FormularNamensraum:formElements>
<FormularNamensraum:FormElement label="Nachname" visible="true">
<FormularNamensraum:fields>
<Input width="100%" id="oInput" />
</FormularNamensraum:fields>
</FormularNamensraum:FormElement>
</FormularNamensraum:formElements>
</FormularNamensraum:FormContainer>
</FormularNamensraum:formContainers>
<FormularNamensraum:layout>
<FormularNamensraum:ResponsiveGridLayout id="oLayout" />
</FormularNamensraum:layout>
</FormularNamensraum:Form>
</content>
</Page>
</pages>
</App>
</mvc:View>
Check the API Reference for more info on forms and the other elements in the future.
Upvotes: 1