Custom Ticket Fields
Trac supports adding custom, user-defined fields to the ticket module. With custom fields you can add typed, site-specific properties to tickets.
Configuration
Configure custom ticket fields in the [ticket-custom] section of trac.ini.
The syntax of each field definition is:
FIELD_NAME = TYPE (FIELD_NAME.OPTION = VALUE) ...
The example below should help to explain the syntax.
Field Names
A field name can only contain lowercase letters a-z, uppercase letters A-Z or digits 0-9, and must not start with a leading digit.
The following field names are reserved and can not be used for custom fields:
- cc
- changetime
- col
- comment
- component
- desc
- description
- format
- group
- groupdesc
- id
- keywords
- max
- milestone
- or
- order
- owner
- page
- priority
- report
- reporter
- resolution
- row
- severity
- status
- summary
- time
- type
- verbose
- version
Available Field Types and Options
- text: A simple (one line) text field.
- label: Descriptive label.
- value: Default value.
- order: Sort order placement relative to other custom fields.
- max_size: Maximum allowed size in characters (Since 1.3.2).
- format: One of:
plainfor plain textwikifor wiki formatted contentreferenceto treat the content as a queryable valuelistto interpret the content as a list of queryable values, separated by whitespace
- ticketlink_query: Query for linkifying ticket values.
Not applicable for format
plainandwiki.
- checkbox: A boolean value check box.
- label: Descriptive label.
- value: Default value, 0 or 1.
- order: Sort order placement.
- ticketlink_query: Query for linkifying ticket values.
- select: Drop-down select box. Uses a list of values.
- label: Descriptive label.
- options: List of values, separated by | (vertical pipe).
- value: Default value (one of the values from options).
- order: Sort order placement.
- ticketlink_query: Query for linkifying ticket values.
- radio: Radio buttons. Essentially the same as select.
- label: Descriptive label.
- options: List of values, separated by | (vertical pipe).
- value: Default value, one of the values from options.
- order: Sort order placement.
- ticketlink_query: Query for linkifying ticket values.
- textarea: Multi-line text area.
- label: Descriptive label.
- value: Default text.
- rows: Height in lines.
- order: Sort order placement.
- max_size: Maximum allowed size in characters (Since 1.3.2).
- format: Either
plainfor plain text orwikito interpret the content as WikiFormatting.
- time: Date and time picker. (Since 1.1.1)
- label: Descriptive label.
- value: Default date.
- order: Sort order placement.
- format: One of:
relativefor relative dates.datefor absolute dates.datetimefor absolute date and time values.
If the label is not specified, it will be created by capitalizing the custom field name and replacing underscores with whitespaces.
Macros will be expanded when rendering textarea fields with format wiki, but not when rendering text fields with format wiki.
For applicable fields, the ticketlink_query option
overrides [query] ticketlink_query, and the format is the same as
that option. When the ticketlink_query option
is not specified, [query] ticketlink_query is used to
linkify the field.
Sample Configuration
Note: To make a select type field optional, specify a leading | in fieldname.options (e.g. test_five).
Reports Involving Custom Fields
Custom ticket fields are stored in the ticket_custom table, not in the ticket table. So to display the values from custom fields in a report, you will need a join on the 2 tables. Let's use an example with a custom ticket field called progress.
Note: This will only show tickets that have progress set in them. This is not the same as showing all tickets. If you created this custom ticket field after you have already created some tickets, they will not have that field defined, and thus they will never show up on this ticket query. If you go back and modify those tickets, the field will be defined, and they will appear in the query.
However, if you want to show all ticket entries (with progress defined and without), you need to use a JOIN for every custom field that is in the query:
Note in particular the LEFT OUTER JOIN statement here.
Note that option names in trac.ini are case-insensitive, so even if your option name includes uppercase characters:
you must use lowercase in the SQL: AND c.name = 'progress_type'.
See also: TracTickets, TracIni

