Edit or create an item, save the contents, and reset the controls in an Edit Form control.
These functions are often invoked from the OnSelect formula of a Button or Image control so that the user can save edits, abandon edits, or create a record. You can use controls and these functions together to create a complete solution.
These functions return no values.
Use the SubmitForm function in the OnSelect property of a Button control to save any changes in a Form control to the data source.
Before submitting any changes, this function checks for validation issues with any field that's marked as required or that has one or more constraints on its value. This behavior matches that of the Validate function.
SubmitForm also checks the Valid property of the Form, which is an aggregation of all the Valid properties of the Card controls that the Form control contains. If a problem occurs, the data isn't submitted, and the Error and ErrorKind properties of the Form control are set accordingly.
If validation passes, SubmitForm submits the change to the data source.
The EditForm function changes the Form control's mode to FormMode.Edit. In this mode, the contents of the Form control's Item property are used to populate the form. If the SubmitForm function runs when the form is in this mode, a record is changed, not created. FormMode.Edit is the default for the Form control.
The NewForm function changes the Form control's mode to FormMode.New. In this mode, the contents of the Form control's Item property are ignored, and the default values of the Form's DataSource property populate the form. If the SubmitForm function runs when the form is in this mode, a record is created, not changed.
The ResetForm function resets the contents of a form to their initial values, before the user made any changes. If the form is in FormMode.New mode, the form is reset to FormMode.Edit mode. The OnReset behavior of the form control also runs.
SubmitForm( FormName )
EditForm( FormName )
NewForm( FormName )
ResetForm( FormName )
See Understand data forms for complete examples.
SubmitForm( EditForm )
When the user selects the Save button, any changes in the Form control are submitted to the underlying data source.
ResetForm( EditForm ); Back()
When the user selects the Cancel button, the values in the Form control are reset to what they were before the user started to edit it, the previous screen reappears, and the Form control is returned to Edit mode if it was in New mode.
NewForm( EditForm ); Navigate( EditScreen, None )
When the user selects the New button, the Form control switches to New mode, the default values for the Form control's data source populate that control, and the screen that contains the Form control appears. When the SubmitForm function runs, a record is created instead of updated.