apache > cocoon
 
Font size:      

Cocoon Forms: multivaluefield widget (2.1 legacy document)

Warning
This document was copied as is from the Cocoon 2.1 documentation, but has not yet been fully reviewed or moved to its new home.

Concept

The fd:multivaluefield is similar to the field widget but can take multiple values. Its purpose is to handle those (HTML) form controls which submit their multiple values as multiple (HTTP) request parameters with the same name. A multivaluefield should always have an fd:datatype element combined with a fd:selection-list, since the user will have to select values from this list.

The fd:multivaluefield could be rendered as a list of checkboxes or as a listbox in which the user can select multiple items. The CForms stylesheets also include a styling option to render them as a "double list", i.e. a list of available and selected values.

The setValue and getValue methods of the multivaluefield take respectively return arrays of objects (i.e. Object[]). The type of the objects in these arrays should match the datatype declared for the widget.

Configuration

<fd:multivaluefield id="...">
  <fd:label>...</fd:label>
  <fd:help>...</fd:help>
  <fd:hint>...</fd:hint>
  <fd:datatype base="...">
    [...]
  </fd:datatype>
  <fd:selection-list>
    [...]
  </fd:selection-list>
  <fd:validation>
    [...]
  </fd:validation>
  <fd:on-value-changed>
     [...]
  </fd:on-value-changed>
</fd:multivaluefield>

Most of the elements and attributes have the same meaning as for the field widget.

Note: A multivaluefield cannot have a required attribute, instead you should use the value-count validator to check the number of values the user has selected.

Comments

add your comments