Configuring Schemas for linked hints_ labels_ and Read-only Form Text fields

About this task

WebForms Designer users can create links from their Form to an SDL Tridion Component from three different locations:

  • from the label of any Field
  • from the hint text of any Field
  • from the text of any Read-Only Form Text Field

In each of these locations, the WebForms Designer user can:

  • create a hyperlink that points to a Component
  • place the contents of one field of a Component in that location

The WebForms Designer User Manual explains in more detail how this is done.

However, when the WebForms Designer user chooses to place the contents of a Component directly in the location of the label, hint text or read-only text, that user can only select a Component based on one Schema.

By default, all Components must use the ComponentLinkText Schema, found in the folder Building Blocks/Tridion WebForms/Component Linking Example/ in the WebForms Publication. This Schema consists of one Format Area.

You can change the types of Components that WebForms Designer users can select by configuring a different Schema for them to select. This section explains how to do this.

Procedure

  1. To configure a different Schema to select for linked items, decide first which Schema you want to use as a basis for Components that WebForms Designer users can select to link to. You can use an existing Schema, or create a new Schema.
  2. Next, create one or more Components based on this Schema, if you did not create any already.
  3. Open a Component based on your selected Schema and do the following:
    • Select the Source tab of the Component.
    • Search for the root tag (normally called Content) in the Component. This tag has an attribute xmlns, which is set to the target namespace of the Schema. This value is something like uuid:512A612E-29F9-4045-B7B7-1F2F998F2385.
    • Copy-paste this value to a temporary text file.
    • Identify one Field in the Component that you would like to display when the Component is selected as a linked hint, label or text target and type its name in the same temporary text file.
    • Close the Component (there is no need to save, because you made no changes).
  4. Open the WebForms XSLT Component Template and select the Dynamic Template tab. The root tag of this Dynamic Template is <xsl:stylesheet> and it contains a number of namespace declarations as attributes. Do the following:
    • Add a new attribute xmlns:mylinkedns to the xsl:stylesheet tag, where mylinkedns is a name of your choosing to identify the namespace of the Schema you are using.
    • Set the value of this new attribute to the namespace identifier that you copy-pasted from the Component source.
    • In the same tag, find the attribute exclude-result-prefixes, which contains a list of namespace prefixes separated by spaces. Add the name of your namespace (for example, mylinkedns) to this list.
    • Save and close the WebForms XSLT Component Template.
  5. Start Field Type Editor.
  6. For each Field Type for which you want to enable WebForms Designer users to select Components of this Schema for linked hints, labels, and texts, do the following:
    • Open the Field Type.
    • Select the Expand XSLT tab of the Field Type.
    • Add the same xmlns:mylinkedns attribute to the xsl:stylesheet root tag that you added in the WebForms XSLT Component Template.
    • Find the Expand implementation for the twf:linklabel and twf:linkhint properties by searching for these strings. The XML fragments you find look something like this:
      <xsl:when test="twf:linklabel">
        <xsl:choose>
          <xsl:when test="twf:linklabel/twf:rendertype='Render As Link'">
            <twf:label>
              <xsl:copy-of select="twf:linklabel">
            </twf:label>
          </xsl:when>
          <xsl:otherwise>
            <twf:label>
              <xsl:call-template name="resolveInlineComponentLinks">
                <xsl:with-param name="LabelContents"
                select="document(string(twf:linklabel/
                twf:webformscomponentlink/@xlink:href))/tcm:Component/
                tcm:Data/tcm:Content/wfcl:ComponentLinkText/
                wfcl:labeltext"/>
              </xsl:call-template>
            </twf:label>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
    • Replace the bold part of this fragment (that is wfcl:ComponentLinkText/wfcl:labeltext) with an XPath for your Schema, pointing to the field you want to insert in this location, prefacing each element in the path with your namespace. For example, if the root element name of your Schema is Content (default) and your field is called TextToLinkTo, replace the text with mylinkedns:Content/mylinkedns:TextToLinkTo.
    • Save and close the Field Type, and close Field Type Editor.
  7. To test your implementation, do the following:
    1. Start WebForms Designer.
    2. Create a new Form based on a Form Schema that contains one of your modified Field Types.
    3. Add a Field of one of your modified Field Types to the Form.
    4. Access the Linked Label and/or Linked Hint properties of the Field, and set its Component subproperty to a Component of the Schema you configured.
    5. Save and close the Form, and close WebForms Designer.
    6. Add your newly created Form to a Page as a Component, combined with the WebForms XSLT Component Template, and preview the resulting Component Presentation in the Page window.
    7. Verify that the preview of your Component Presentation displays the correct content, originating from the Component you selected.