Option Form Element

The <option> element lets you specify allowable choices for a field, which can be represented in a drop down, for example. It's represented by the dw.web.FormOption API class.

Attribute Description
optionid The identifier of the option.
value The option's value.
label The option label value. This field can be a key.
default The option's default value.

This element must be a child of <options>, with the following structure:

<options>
	<option>
	<option>
	<option>
</options>

The following example specifies a list of identifying password questions in the profile form:

<field formid="question" label="forms.profile.018" type="string" mandatory="false" binding="passwordQuestion">
	<options>
		<option optionid="MothersMaidenName" value="Mother's Maiden Name" label="forms.profile.019"/>
		<option optionid="MakeOfFirstCar" value="Make of First Car" label="forms.profile.020"/>
		<option optionid="FavouritePetsName" value="Favourite Pet's Name" label="forms.profile.021"/>
		<option optionid="FathersFirstName" value="Father's First Name" label="forms.profile.022"/>
		<option optionid="PlaceOfBirth" value="Place of Birth" label="forms.profile.023"/>
	</options>	
</field>

Object Binding

You can also define option data dynamically by binding methods to an object within the form definition. For example, you could modify the previous profile form to dynamically create a list of password question via a custom business object. In the Business Manager, you would create a custom object and then add the questions as attributes. In Studio, you would modify the form so that it binds a passwordQuestion method to the custom object, as follows.

<field formid="question" label="Password Question" type="string" mandatory="false" binding="passwordQuestion">
	<options optionid-binding="UUID" value-binding="UUID" label-binding="question"/>
	</options>
</field>

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 and to tailor advertising. By continuing to use this site you are giving us your consent to do this.