Adding Form to a Simple Page

Note: Spartacus 4.x is no longer maintained. Please upgrade to the latest version.

Note: Spartacus 4.x was tested with SAP Commerce Cloud versions 1905 to 2205. Spartacus 4.x has not been verified to work with (and is not guaranteed to work with) SAP Commerce Cloud 2211 or later releases.

This page explains how to add a form to a simple page.

Procedure

To add a form to a simple page:

  • Create JSON form definition for a new form. For more information, see Form Definition - JSON Structure.

  • In the ImpEx file, create a YFormDefinition with a reference to the newly created JSON definition:

      INSERT_UPDATE YFormDefinition; applicationId[unique = true]; formId[unique = true]; version; title; description; content[translator = de.hybris.    platform.commerceservices.impex.impl.FileLoaderValueTranslator];
      ; insurance ; new_form ; 1 ; New Form ; "New Form" ; $siteResource/forms/new-form.json
    
  • Create a new CMS component (e.g.,”NewFormComponent”) with a reference to the previously added YFormDefinition:

      INSERT_UPDATE CMSFormSubmitComponent; $contentCV[unique = true];    uid[unique = true]; name; visible; &componentRef; applicationId;   formId
      ; ; NewFormComponent ; New Form Component ; true ;  NewFormComponent ; insurance ; new_form
    
  • Connect the component with a page through a content slot:

      INSERT_UPDATE ContentSlot; $contentCV[unique = true]; uid[unique    = true]; name; active; cmsComponents(&componentRef);
      ; ; Section2Slot-newFormPage ; Section2 Slot for New Form Page ;    true ; NewFormComponent