Salesforce B2C Commerce 23.5 > Developing Your Site > Legacy Developer Documentation > Site Genesis > SGJC Forms > Form Definition Elements

Options Form Element

The <options> element lets you specify a number of options within the context of a field. It must be a child of <field>. This element is represented by the dw.web.FormOptions API class.

Attribute Description
optionid-binding Identifies the binding method to use when getting and setting option ID values.
value-binding The values of the option that are allowed, bound to an object.
label-binding The option label presented on the browser, bound to an object.

The previous attributes are similar to the <option> attributes, but they can be bound to an object.

Example

This example (also used for <option>) specifies a list of identifying password questions in the profile form:

<field formid="question" label="Password Question" type="string" mandatory="false" binding="passwordQuestion">
	<options>
		<option optionid="MothersMaidenName" value="Mother's Maiden Name"/>
		<option optionid="MakeOfFirstCar" value="Make of First Car"/>
		<option optionid="FavoritePetsName" value="Favorite Pet's Name"/>
		<option optionid="FathersFirstName" value="Father's First Name"/>
		<option optionid="PlaceOfBirth" value="Place of Birth"/>
	</options>
</field>

In the previous example, the options are hard coded. You can also build this information dynamically by binding metadata to objects, which represent that data as in-memory tables.

Using the example, the SiteGenesis application currently hardcodes country abbreviations in the customeraddress form, as follows:

<field formid="country" label="forms.country" type="string" mandatory="true" binding="countryCode"
	missing-error="forms.customeraddress.country.missing-error">
	<options>
		<option optionid="" 	label="forms.customeraddress.selectone"	value=""/>
		<option optionid="US" 	label="country.unitedstates"	value="US"/>
		<option optionid="DE" 	label="country.germany" 	value="DE"/>
		<option optionid="CA" 	label="country.canada" 	value="CA"/>
	</options>	
</field>

With object binding, the pipeline could instead perform within a loop, a dynamic get to a country object as follows, picking up new countries as they are supported by the storefront.

<field formid="country" label="forms.country.countries" type="string" mandatory="true" binding="countryCode">
	<options optionid-binding="UUID" value-binding="UUID" label-binding="country"/>
	</options>

See Object Binding with Forms.

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.