Skip to main content
With the $wsForm module, you can use form data dynamically in the frontend, load form fields, and read out submitted form data.

Module overview

Example / excerpt of $wsForm
JSON output
Note: ƒ() denotes a function. Variables overview

Templates

Forms are used everywhere in the shop and on all templates. These forms are, for example:
  • Contact form
  • Withdrawal form
  • Question about the product
  • Password reset

Variables

$wsForm.inquiryId

Contains the unique ID of a form inquiry after successful sending. With this ID, the form data can be retrieved via load().

Methods

$wsForm.loadType()

Loads the structure of a form (fields, labels, validations) by the form ID. Signature
$wsForm.loadType(inquiryId)
Return value
map - Map with the form properties and fields.
Parameters Example that outputs all properties of each form field:

Variables of the field objects

The $wsForm.loadtype() method returns an object per field (in this example $myField) with the following properties. If a RuleSet (inquiry - Forms) is assigned to the form, the attributes required and label are automatically adjusted by the rules defined there.

$wsForm.loadAllTypes()

Loads all available form types of the shop Signature
$wsForm.loadAllTypes()
Return value
array - List of all available form types.
Example that iterates over all available form types.

$wsForm.load()

Loads the submitted data of a sent form. Signature
$wsForm.load(inquiryId)
Return value
map - Map with the inquiry data.
Parameters Example that checks whether the form was successfully sent and loads the data.
Procedure:
  • Create action “InquirySend
  • Check whether sending was successful
  • Load form data via the Inquiry ID
The following variables are available after the inquiry data has been loaded with load():

Variables of the inquiry data

$myInquiry.id

Returns the unique ID of the form inquiry.

$myInquiry.formId

Returns the ID of the form used.

$myInquiry.createdAt

Returns the time of sending.

$myInquiry.submitter

Returns a map with data about the sender.

$myInquiry.submitter.email

Returns the email address of the sender.

$myInquiry.submitter.sessionId

Returns the session ID during which the form was sent.

$myInquiry.submitter.ipAddress

Returns the IP address of the sender.

$myInquiry.form

Returns the data of the form inquiry that the customer entered in the shop as a map.

$myInquiry.form.”fieldName”.label

Returns the display name of the field.

$myInquiry.form.”fieldName”.value

Returns the entered value of the field.

Actions

Actions for this module that trigger changes are documented separately in the “Actions” chapter: Inquiry

Example for displaying form fields

Function - loadType

The function $wsForm.loadType() takes the name of the form as an argument and is used to access the properties and fields of the form. The fields and associated properties of the contact form can then be loaded and read as follows.
The output could then look like this:

Function - load

The function $wsForm.load() is used to access the submitted data of a sent form. This can be used, for example, to show the user the submitted information in the frontend or via email. This example checks whether the form was successfully sent and loads the inquiry data. This is done as follows (commented out so that the output is not displayed directly in the frontend):
The output in the browser’s developer console could then look like this:

Example: display data in the frontend

This example loads and displays the data of a sent form using the $wsForm.load() function.
You can find more examples of displaying and loading form data here:
Practical examples: forms