Developers/Concepts/KeyFields

From Tine 2.0 - Wiki

< Developers
STATUS: PARTLY IMPLEMENTED (FILTER & ADMIN UI WIDGETS MISSING)
RELEASED IN: MILAN


Key Fields

Key fields hold 1:n relations to records which are only present in config but not as separate SQL table rows.

Example: Priority {LOW|NORMAL|HIGH|URGENT}

Key field definition is done in configuration and thus included in the registry. So key fields are not part of the object graph and are not resolved on record read. It's the client which resolves the keys.

Key Field Definition

A Key Field Definition is part of the application config class and therefore PHP code which contains:

  • key name (from config)
  • record definition (Appname_Model_ConfigName) (defaults to id|value)
  • default/fallback records/value might be done by code interceptors

Key Field Record Model

The model of the key field records are standard Tine 2.0 models. The default record is Tinebase_Model_KeyField which only comes with the fields

  • id -> getId()
  • value -> getTitle()
  • icon_16
  • system -> not deletable

Key Field Config Data

Key field config data is a JSON structure which is stored in the value column of the config table describing the available keys/values and the default key:

{
  records: [
    {"id": "LOW", "value": "low"},
    {"id": "NORMAL", "value": "normal"},
    {"id": "HIGH", "value": "high"},
    {"id": "URGENT", "value": "urgent"},
  ],
  "default": "NORMAL"
}

The initial key field records are created in setup process via the initializer. There the translations of the keys are defined in comment strings to be available in the clients translation system.

Key Field API Support and Widgets

  • Select Combo widget
  • List Renderer widget
  • Filter Model widget
  • Admin Config widget