Using Forms in Templates

Templates provide the page display logic. Use templates to process form field elements or actions as entered in the browser. Templates use:

  • Form definition references to the in-memory form instances
  • The Pipeline Dictionary to transport the data to and from the browser
  1. Refer to the example data in Creating a Form Definitions.
  2. Create a template sendstuff.isml. This template uses form data object references to render browser entry details and validate customer entry for the following checkbox fields:
    • catalogSend
    • emailSend
  3. Enter these lines in the template header:
    <isdecorate template="pagetypes/pt_service">
    <iscontent type="text/html" charset="UTF-8" compact="true">
  4. Enter these lines, which includes the util/modules template, which processes < isinputfield> calls.
    <isinclude template="util/modules">
    <div id="service">
  5. Enter these lines, which defines browser message display.
    <h1>${Resource.msg('user.sendstuff.010','user',null)}</h1>
    <div class="editprofile">
    <h2>${Resource.msg('user.sendstuff.011','user',null)}</h2>
    <form action="${URLUtils.httpsContinue()}" method="post" id="apply">
    <h3>${Resource.msg('user.sendstuff.012','user',null)}</h3>
  6. Enter the following lines. The isinputfield tag renders an input field using the field definitions in sendstuff form. When the HTML form is submitted, the user values are accessible from the CurrentForms.sendstuff object in the Pipeline Dictionary.
    The < isinputfield> element renders input fields in SiteGenesis.
    <div id="sendstuff">
    	<fieldset>
    		<table class="simple">
    			<tr><isinputfield formfield="${pdict.CurrentForms.sendstuff.email}" type="checkbox"></tr>
    			<tr><isinputfield formfield="${pdict.CurrentForms.sendstuff.catalog}" type="checkbox"></tr>
    		</table>
    	</fieldset>
    </div>
  7. Enter the following lines, which represent a browser action (button).
    					<h3>${Resource.msg('user.sendstuff.012','user',null)}</h3>
    				<div id="editprofile">
    					<fieldset>
    						<input class="image imageright" 
    						          type="image" 
    						          name="${pdict.CurrentForms.sendstuff.apply.htmlName}" 
    						          value="Edit" 
    						          src="${URLUtils.staticURL('/images/bttn_apply.gif')}" />
    					</fieldset>
    				</div>
    			</form>
    		</div>
    	</div>
    ...
    </isdecorate>
  8. Continue with this example: Using Form Pipelets.

These are other examples of how Salesforce B2C Commerce forms are accessed in templates.

<input> Element

Reads the coupon code.

<input type="text" class="couponinput" name="${pdict.CurrentForms.cart.couponCode.htmlName}" 
alt="${Resource.msg('cart.entercouponcode','checkout',null)}"/>

<isif> Element

Checks if the current customer is registered.

<isif condition="${pdict.CurrentCustomer.registered}">  

<isprint> Element

Prints the phone number portion of the address.

<isprint value="${pdict.Address.phone}">"  

<isinputfield> Element

Reads the first name from the customer address.

<isinputfield formfield="${pdict.CurrentForms.profile.address.firstname}" type="input">  

<isloop> Element

Loop reads product options from the form.

<isloop items="${lineItem.optionProductLineItems}" var="oli">  

<select element>

Displays select box for "edit addresses" for the Wish List page.

<select class="selectbox" name="editAddress" id="editAddress">