Changes between Version 1 and Version 2 of TracTicketsCustomFields


Ignore:
Timestamp:
09/29/11 01:15:08 (13 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v1 v2  
    1818   * value: Default value. 
    1919   * order: Sort order placement. (Determines relative placement in forms with respect to other custom fields.) 
     20   * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. (''since 0.11.3'') 
    2021 * '''checkbox''': A boolean value check box. 
    2122   * label: Descriptive label. 
     
    3031   * label: Descriptive label. 
    3132   * options: List of values, separated by '''|''' (vertical pipe). 
    32    * value: Default value (Item #, starting at 0). 
     33   * value: Default value (one of the values from options). 
    3334   * order: Sort order placement. 
    3435 * '''textarea''': Multi-line text area. 
     
    3839   * rows: Height in lines. 
    3940   * order: Sort order placement. 
     41   * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. (''since 0.11.3'') 
    4042 
    4143=== Sample Config === 
     
    4850test_two = text 
    4951test_two.label = Another text-box 
    50 test_two.value = Just a default value 
     52test_two.value = Default [mailto:joe@nospam.com owner] 
     53test_two.format = wiki 
    5154 
    5255test_three = checkbox 
     
    6265test_five.label = Radio buttons are fun 
    6366test_five.options = uno|dos|tres|cuatro|cinco 
    64 test_five.value = 1 
     67test_five.value = dos 
    6568 
    6669test_six = textarea 
     
    107110Note in particular the `LEFT OUTER JOIN` statement here. 
    108111 
     112=== Updating the database === 
     113 
     114As noted above, any tickets created before a custom field has been defined will not have a value for that field. Here's a bit of SQL (tested with SQLite) that you can run directly on the Trac database to set an initial value for custom ticket fields. Inserts the default value of 'None' into a custom field called 'request_source' for all tickets that have no existing value: 
     115 
     116{{{ 
     117#!sql 
     118INSERT INTO ticket_custom 
     119   (ticket, name, value) 
     120   SELECT  
     121      id AS ticket, 
     122      'request_source' AS name, 
     123      'None' AS value 
     124   FROM ticket  
     125   WHERE id NOT IN ( 
     126      SELECT ticket FROM ticket_custom 
     127   ); 
     128}}} 
     129 
     130If you added multiple custom fields at different points in time, you should be more specific in the subquery on table {{{ticket}}} by adding the exact custom field name to the query: 
     131 
     132{{{ 
     133#!sql 
     134INSERT INTO ticket_custom 
     135   (ticket, name, value) 
     136   SELECT  
     137      id AS ticket, 
     138      'request_source' AS name, 
     139      'None' AS value 
     140   FROM ticket  
     141   WHERE id NOT IN ( 
     142      SELECT ticket FROM ticket_custom WHERE name = 'request_source' 
     143   ); 
     144}}} 
     145 
    109146---- 
    110147See also: TracTickets, TracIni