Monday, April 22, 2013

Converting the multifield to use something other than text

The traditional use of the multifield is to allow users to enter a number of text fields, which are then stored all in one location in the jcr.

However the type of component that is rendered is identified by the fieldConfig property. Which defaults to a text field.

Here is a sample structure to support changing the default type to a drop down selection;

{
  "xtype": "multifield",
  "name": "./shadow",
  "fieldlabel": "stuff",
  "jcr:primaryType": "cq:Widget",
  "fieldConfig": {
    "xtype": "selection",
    "type": "select",
    "jcr:primaryType": "nt:unstructured",
    "options": {
      "jcr:primaryType": "cq:WidgetCollection",
      "o1": {
        "value": "google",
        "jcr:primaryType": "nt:unstructured",
        "text": "google"
      },
      "02": {
        "value": "yahoo",
        "jcr:primaryType": "nt:unstructured",
        "text": "yahoo"
      }
    }
  }
}