Changes between Version 1 and Version 2 of TracTicketsCustomFields
- Timestamp:
- Apr 9, 2008, 4:17:48 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracTicketsCustomFields
v1 v2 1 1 = Custom Ticket Fields = 2 Trac support adding custom, user-defined, fields to the ticket module. Using custom fields, you can add typed, site-specific,properties to tickets.2 Trac supports adding custom, user-defined fields to the ticket module. Using custom fields, you can add typed, site-specific properties to tickets. 3 3 4 '''Note: In Trac 0.8, this feature is still experimental.''' 5 6 == Configuriation == 7 Configuring custom ticket fields is done in the TracIni config file. 8 9 All field definitions should be under a section named [ticket-custom] in the ini-file. 4 == Configuration == 5 Configuring custom ticket fields is done in the [wiki:TracIni trac.ini] file. All field definitions should be under a section named `[ticket-custom]`. 10 6 11 7 The syntax of each field definition is: … … 15 11 ... 16 12 }}} 17 Looking at the example below should helpexplain the syntax.13 The example below should help to explain the syntax. 18 14 19 15 === Available Field Types and Options === … … 21 17 * label: Descriptive label. 22 18 * value: Default value. 23 * order: Sort order placement. (Determines relative placement in forms .)19 * order: Sort order placement. (Determines relative placement in forms with respect to other custom fields.) 24 20 * '''checkbox''': A boolean value check box. 25 21 * label: Descriptive label. … … 27 23 * order: Sort order placement. 28 24 * '''select''': Drop-down select box. Uses a list of values. 25 * label: Descriptive label. 29 26 * options: List of values, separated by '''|''' (vertical pipe). 30 * value: Default value ( Item #, starting at 0).27 * value: Default value (one of the values from options). 31 28 * order: Sort order placement. 32 29 * '''radio''': Radio buttons. Essentially the same as '''select'''. … … 38 35 * label: Descriptive label. 39 36 * value: Default text. 40 * width: Width in columns.41 * height: Height in lines.37 * cols: Width in columns. 38 * rows: Height in lines. 42 39 * order: Sort order placement. 43 40 … … 45 42 {{{ 46 43 [ticket-custom] 44 47 45 test_one = text 48 46 test_one.label = Just a text box … … 59 57 test_four.label = My selectbox 60 58 test_four.options = one|two|third option|four 61 test_four.value = 259 test_four.value = two 62 60 63 61 test_five = radio … … 69 67 test_six.label = This is a large textarea 70 68 test_six.value = Default text 71 test_six. width= 6072 test_six. height= 3069 test_six.cols = 60 70 test_six.rows = 30 73 71 }}} 72 73 ''Note: To make entering an option for a `select` type field optional, specify a leading `|` in the `fieldname.options` option.'' 74 75 === Reports Involving Custom Fields === 76 77 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`. 78 79 {{{ 80 #!sql 81 SELECT p.value AS __color__, 82 id AS ticket, summary, owner, c.value AS progress 83 FROM ticket t, enum p, ticket_custom c 84 WHERE status IN ('assigned') AND t.id = c.ticket AND c.name = 'progress' 85 AND p.name = t.priority AND p.type = 'priority' 86 ORDER BY p.value 87 }}} 88 '''Note''' that this will only show tickets that have progress set in them, which 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. If that's all you want, you're set. 89 90 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. 91 {{{ 92 #!sql 93 SELECT p.value AS __color__, 94 id AS ticket, summary, component, version, milestone, severity, 95 (CASE status WHEN 'assigned' THEN owner||' *' ELSE owner END) AS owner, 96 time AS created, 97 changetime AS _changetime, description AS _description, 98 reporter AS _reporter, 99 (CASE WHEN c.value = '0' THEN 'None' ELSE c.value END) AS progress 100 FROM ticket t 101 LEFT OUTER JOIN ticket_custom c ON (t.id = c.ticket AND c.name = 'progress') 102 JOIN enum p ON p.name = t.priority AND p.type='priority' 103 WHERE status IN ('new', 'assigned', 'reopened') 104 ORDER BY p.value, milestone, severity, time 105 }}} 106 107 Note in particular the `LEFT OUTER JOIN` statement here. 74 108 75 109 ----