Cert++
Close

Adding a field to an existing SFRA form through a custom cartridge

Key Takeaway

Make every change in a custom cartridge to the left of app_storefront_base, and save submitted form data in a route:BeforeComplete handler.

An SFRA storefront form has three parts. A form definition is an XML file that lists the fields and their validation rules. A controller turns that definition into a JSON form object. An ISML template then renders the form object. To add a field to a form that ships in app_storefront_base, you make every change in your own custom cartridge and never edit the base cartridge. Leaving the base cartridge untouched means you can still take SFRA security updates, bug fixes and new features.

Working in a custom cartridge

Do not edit app_storefront_base or the server module. Editing them voids the backward-compatibility guarantee and makes it harder to adopt fixes.

Instead, put your customizations in a custom cartridge. Place the custom cartridge to the left of app_storefront_base on the cartridge path. You configure the cartridge path in Business Manager.

The platform searches the cartridge path from left to right and uses the first matching controller or template. Because of that search order, a cartridge earlier on the path can override one later on the path.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a requirement to accept, validate, and persist information from a storefront customer, modify the appearance of a form, add validation and cross-site request forgery (CSRF) protection, and use bindings to process fields

0/9

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.