What Is a Form Definition

When working with Salesforce B2C Commerce forms, you define form properties and data validation within an XML-based form definition (model). Form definitions are stored in the forms folder of a cartridge (cartridge/forms/default). Within a pipeline, you use form pipelets to create in-memory data constructs based on one or more form definitions.

The form.xsd schema file (XSD), which identifies the allowed elements and attributes for form files, is included in the general schema .zip file provided by B2C Commerce.

Use this file as a guideline for defining your form definitions.

The Pipeline Dictionary stores per session key value pairs using elements of the form definition as the keys and consumer input data as the values. You can also use forms just for rendering. They don't need to contain consumer input data.

There is only one form instance for each form definition per session. The system stores this information in the Pipeline Dictionary using the value CurrentForms to provide access to these form instances. You can reference a form within a template or script via its definition name, which is derived from its file name. You can access all form fields as alias expressions and as B2C Commerce script expressions; and use these expressions to copy (via binding) the value of a field directly into a business object.

Form definitions
  • Describe the form data entry parameters.
  • Let you declare form parameters as mandatory or optional.
  • Support regular expression-based rules that can be used to determine if the content submitted by the client is valid.
  • Starting in 15.8, you can specify a custom validation function for form fields. For more information, see Field Form Element.
  • Are stored in XML files in a cartridge.
  • Can define dynamic or hard-coded data representation.
  • Can be taken directly from the metadata system.
Form objects (in memory)
  • Contain all information necessary for form display (for example, name, value, label, description and error message).
  • Handle the formatting (for example, numeric values are reformatted after validation in the correct format).
  • Represent the HTTP form data submitted by a client browser.
  • Provide a container for multiple form parameters submitted by a client.
  • Are stored in session memory.
  • Can be bound with business objects and stored on a server.
  • Can be derived from B2C Commerce metadata via the object-def and attribute-def form field attributes. See Extracting Form Field Parameters from Metadata.

Refer to a form instance by the form definition's XML file name, as follows:


These are some sample expressions:

<isif condition="${pdict.CurrentForms.checkout.selectedpm.options.CreditCard.checked}">
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.