Introduza a conta escolar ou profissional para começar.
View, edit, or create an item, save the contents, and reset the controls in an Edit form control.
These functions change the state of the Edit form control. The form control can be in one of these modes:
|FormMode.Edit||The form is populated with an existing record and the user can modify the values of the fields. Once complete, the user can save the changes to the record.|
|FormMode.New||The form is populates with default values and the user can modify the values of the fields. Once complete, the user can add the record to the data source.|
|FormMode.View||The form is populated with an existing record but the user cannot modify the values of the fields.|
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. You can also reset individual controls with the Reset function but only from within the form.
The ViewForm function changes the Form control's mode to FormMode.View. In this mode, the contents of the Form control's Item property are used to populate the form. The SubmitForm and RestForm functions have no effect when in this mode.
The current mode can be read through the Mode property. The mode also determines the value of the DisplayMode property which can be used by data cards and controls within the form control. Often, the data card's DisplayMode property will be set to Parent.DisplayMode (refernceing the form) as will the control's DisplayMode property (referncing the data card):
|FormMode.Edit||DisplayMode.Edit||Data cards and controls are editable, ready to accept changes to a record.|
|FormMode.New||DisplayMode.Edit||Data cards and controls are editable, ready to accept a new record.|
|FormMode.View||DisplayMode.View||Data cards and controls are not editable and optimized for viewing.|
SubmitForm( FormName )
EditForm( FormName )
NewForm( FormName )
ResetForm( FormName )
ViewForm( 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.