Hi,
I want to enable validations on a form inside a dialog fragment. Tried to follow the example like here: https://sapui5.hana.ondemand.com/#/sample/sap.m.sample.InputChecked/preview
but it simply doesn't call any of the 3 methods.
How do I bind the Message Manager to the fragment so any input inside it works?
[EDIT]
I tried using the default types validation, and yet not is showing up.
Detail.Controller onInit method has this:
var oMessageManager = sap.ui.getCore().getMessageManager();
oMessageManager.registerObject(this.getView(), true);
On a button press I have this:
var oView = this.getView();
oDialog = sap.ui.xmlfragment("com.tigre.sales.view.AddContactDialog", this);
oView.addDependent(oDialog);
var oContext = this._oODataModel.createEntry("ContactSet", {
success: this._createContactHandler.bind(this),
error: this._createContactHandler.bind(this)
});
oDialog.setBindingContext(oContext);
oDialog.open();
My fragment (AddContactDialog.fragment.xml):
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:semantic="sap.m.semantic" xmlns="sap.m" xmlns:f="sap.ui.layout.form" xmlns:html="http://www.w3.org/1999/xhtml">
<Dialog id="AddContactDialog" title="{i18n>AddContactDialogTitle}">
<content>
<f:SimpleForm columnsL="1" columnsM="1" editable="true" emptySpanL="4" emptySpanM="4" id="newContactSimpleForm" labelSpanL="3" labelSpanM="3" layout="ResponsiveGridLayout" maxContainerCols="2" minWidth="1024" title="{i18n>AddContactDialogTitle}">
<f:content>
<Label text="{i18n>ContactName}" required="true"/>
<Input name="Person" type="Text" id="Person_id" valueLiveUpdate="true" value="{ path: 'Person', type: 'com.tigre.core.types.alphabet'}"/>
<Label text="{i18n>Role}" required="true"/>
<Input name="Role" id="Role_id" valueLiveUpdate="true" value="{ path: 'Role', type: 'sap.ui.model.type.String', constraints:{ maxLength:50 } }"/>
<Label text="{i18n>Email}" required="true"/>
<Input type="Email" placeholder="{i18n>emailPlaceholder}" name="Email" id="Email_id" valueLiveUpdate="true" value="{ path: 'Email', type: 'sap.ui.model.type.String', constraints:{ maxLength:50 } }"/>
<Label text="{i18n>CellPhone}" required="true"/>
<Input name="CellPhone" id="CellPhone_id" valueLiveUpdate="true" value="{ path: 'CellPhone', type: 'sap.ui.model.type.Decimal' , constraints:{ scale:0 } }"/>
</f:content>
</f:SimpleForm>
<Toolbar>
<ToolbarSpacer/>
<Button type="Reject" text="Cancel" press="onCancelButtonPress"/>
<Button type="Accept" text="Save" press="onSaveButtonPress" enabled="{viewModel>/enableCreate}"/>
</Toolbar>
</content>
</Dialog>
</core:FragmentDefinition><br>
What am I doing wrong? Can't I make a form with validation inside a dialog?
Request clarification before answering.
Hi,
Please share code how your creating fragment and opening it in controller. Also check below sample code if anything is missing.
// Common select dialog for all
openLstDlg : function(oEvent) {
if (!this._listDlg) {
this._listDlg = sap.ui.xmlfragment("com.ajva.oplZTR_QUATATN.fragments.List", this);
this.getView().addDependent(this._listDlg);
}
this._listDlg.open();
},
Make sure you added this line. this.getView().addDependent(this._listDlg);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Take a look above or bellow, I've added samples.
var oView = this.getView();
oDialog = sap.ui.xmlfragment("com.tigre.sales.view.AddContactDialog", this);
oView.addDependent(oDialog);
var oContext = this._oODataModel.createEntry("ContactSet", {
success: this._createContactHandler.bind(this),
error: this._createContactHandler.bind(this)
});
oDialog.setBindingContext(oContext);
oDialog.open();
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.