Cert++
Close

Form definition versus plain HTML form for storefront input

Key Takeaway

HTML5 checks such as required and pattern run in the shopper's browser, so a direct request can skip them. For server-side validation, build the form from a form definition that uses mandatory and regexp, load it with server.forms.getForm, and save the data only when the form is valid.

B2C Commerce gives you two ways to collect input from storefront customers: a standard HTML form or a form backed by a form definition. A form definition is an XML file that describes the fields you need, how to validate them, and the system objects to store the data in. Choose a standard HTML form for simple input that is validated on the client. Choose a form definition when you must store data, validate on the server, or change the form's structure by locale.

Standard HTML form or form definition

If the form is simple, doesn't store data, is easily localized, and needs only client-side validation...

Use a standard HTML form.

If the form stores data, needs server-side validation, or has sophisticated localization needs...

Use a form definition, because any one of these needs makes the form complex. Sophisticated localization needs include adding, removing, or rearranging fields, or changing the data object the form data is stored in.

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.