Field Tokens

For Templates

Field Tokens are the mechanism used to display values from your datasource in your templates. If you've used XMod, then you can think of field tokens as the replacement for the old <xmod:field> tag. The token syntax is much simpler. Simply start with two open brackets ([[) followed by the exact name of the field you want to display (this is case-sensitive) and then follow that with two closing brackets (]]). At run-time, XMod Pro will replace that token with the value from that field for each record. There are some usage rules you'll need follow. They are described in the Remarks section.

For Forms

Beginning in version 1.3, you can also use Field Tokens in the attributes of your form's controls to provide a more dynamic form experience. In this context, Field Tokens retreive data from the <SelectCommand>.

There are some usage rules you'll need to adhere to. They are described in the Remarks section.

Syntax

[[fieldName]]
 

Remarks

 

Back to top

Example

Using Field Tokens in a Template

<
xmod:template>
  ...
  <HeaderTemplate>
    <h1>Users</h1>
  </HeaderTemplate>
  <ItemTemplate>
    <strong>Full Name: [[DisplayName]]<br />
    <strong>Address: [[Address1]]<br />
                     [[Address2]]<br />
                     [[City]], [[State]] [[Zip]]<br />
  </ItemTemplate>
  ...
</xmod:template>

Using Field Tokens in a Form Control
This example gets the amount of inventory (StockOnHand) left for the given product and uses that to limit the maximum quantity that can be ordered using the range validator.

<AddForm>
  <SelectCommand CommandText="SELECT StockOnHand FROM Inventory WHERE ProductId = @ProductId">
  <parameter name="ProductId" value='[[Url:ProductId]]' />
  </SelectCommand>
  ...
  <label for="txtQuantity" text="Quantity to Order:" />
  <textbox id="txtQuantity" datafield="Quantity" datatype="int32" />
  <validate type="range" target="txtQuantity" minimumvalue="1" maximumvalue='[[StockOnHand]]'
message='[[Join("You must enter a value between 1 and {0}",[[StockOnHand]]'/>
  ...
</AddForm>
Back to top