Skip to main content

WebForm

The 4D.WebForm class object provides an interface that allows you to handle your webform components. 4D.WebForm objects are instantiated with the webForm command.

Functions and properties

.componentName : [4D.WebFormItem](#webformitem-class)    objects that are available directly as properties
.setError( msg : string)    sends msg as an error message to the web form
.setMessage( msg : string)    sends msg as an information message to the web form
.setWarning( msg : string)    sends msg as a warning message to the web form

.componentName

.componentName : 4D.WebFormItem

Description

The components of webforms are objects that are available directly as properties of these webforms.

The returned objects are of the 4D.WebFormItem class. These objects have functions that you can use to manage your components dynamically.

Example

var myForm: 4D.WebForm
var component: 4D.WebFormItem

myForm = webForm //returns the web form as an object, each property is a component
component = myForm.myImage //returns the myImage component of the web form

info

While myForm may not display typical object properties when examined in the debugger, it behaves as if it were the actual webForm object. You can interact with the underlying webForm object's properties and functions through myForm. For example, you can dynamically manipulate web form components or transmit messages to web pages using specialized functions like myForm.setMessage().

.setError()

.setError( msg : string)

ParameterTypeDescription
msgstring->Error message to display in the web form

Description

The .setError() function sends msg as an error message to the web form.

The function returns a response with a 200 OK status and a __WEBFORM object in the body with a __NOTIFICATION.message property set to msg and a __NOTIFICATION.type set to "error".

Example

exposed function myError()

webForm.setError("My error message")

If the Provide feedback feature is enabled for the event, the message is automatically displayed as a red toast at the bottom of the web form and disappears automatically after 5 seconds:

See also

throw

.setMessage()

.setMessage( msg : string)

ParameterTypeDescription
msgstring->Information message to display in the web form

Description

The .setMessage() function sends msg as an information message to the web form.

The function returns a response with a 200 OK status and a __WEBFORM object in the body with a __NOTIFICATION.message property set to msg and a __NOTIFICATION.type set to "message".

Example

exposed function myMessage()

webForm.setMessage("My information message")

If the Provide feedback feature is enabled for the event, the message is automatically displayed as a green toast at the bottom of the web form and disappears automatically after 5 seconds:

.setWarning()

.setWarning( msg : string)

ParameterTypeDescription
msgstring->Warning message to display in the web form

Description

The .setWarning() function sends msg as a warning message to the web form.

The function returns a response with a 200 OK status and a __WEBFORM object in the body with a __NOTIFICATION.message property set to msg and a __NOTIFICATION.type set to "warning".

Example

exposed function myWarning()

webForm.setWarning("My warning message")

If the Provide feedback feature is enabled for the event, the message is automatically displayed as a yellow toast at the bottom of the web form and disappears automatically after 5 seconds: