See an example of validating a form server-side
Add a new class to your project as a handler for the FormValidateNotification
notification:
The handler will check the ModelState
and Form
field values provided in the notification. If validation fails, we add a ModelError
.
To register the handler, add the following code into the startup pipeline. In this example, the registration is implemented as an extension method to IUmbracoBuilder
and should be called from Program.cs
:
The services available via interfaces IFormService
, IFolderService
, IDataSourceService
and IPrevalueSourceService
trigger following notifications before or after an entity handled by the service is modified.
The "-ing" events allow for the entity being changed to be modified before the operation takes place, or to cancel the operation. The "-ed" events fire after the update is complete.
Both can be wired up using a composer and component:
When a form or folder is moved there is no specific service event. However, information available in the State
dictionary on the notification object can be used to determine whether the item was moved. If so, it can show where it was moved from:
If a folder is being moved, the key within the State
dictionary is "MovedFromParentId"
.
When an entry for a form is rendered in the backoffice, an event is available to allow modification of the record detail. This event is available before the record details are presented to the user. This is shown in the following example: