Custom TVs and additional document fields
In general, values have to be transferred between the $fields array and a temporary array of TV values while you are creating and updating items. Form fields and TVs containing the same data often need different names. Several features of the class definition deal with this (see listing of Event class for an example):
- List the names of the TVs you use as array variable $tvs in the class definition.
- A new object of the given class must use the constructor function to transfer values from the $fields array to the $tvs array if any format or name conversion is required. Elements of the $tvs array are stored as TVs or database fields in the Save routines.
- When an item is recalled for editing, the CustomFields function transfers values from the $fields array (containing the values retrieved from the TVs) to the field names used in your form, converting the format if required.
You can add more TVs to your classes provided you follow the above steps.Look at the pkVenue TV in the Event class for an example.
PubKit already processes quite a few built-in document fields explicitly. More built-in fields such as description can be added using a similar technique. List the names of the fields as a variable in the class definition in an array called $docFields, and adhere to the standard names of the fields in your form. Then they will be saved and retrieved like other fields, with no need to add purpose-built functions.