close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 1 and Version 2 of TracTicketsCustomFields


Ignore:
Timestamp:
Jul 14, 2008, 10:28:17 AM (16 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v1 v2  
    3030   * label: Descriptive label.
    3131   * options: List of values, separated by '''|''' (vertical pipe).
    32    * value: Default value (Item #, starting at 0).
     32   * value: Default value (one of the values from options).
    3333   * order: Sort order placement.
    3434 * '''textarea''': Multi-line text area.
     
    6262test_five.label = Radio buttons are fun
    6363test_five.options = uno|dos|tres|cuatro|cinco
    64 test_five.value = 1
     64test_five.value = dos
    6565
    6666test_six = textarea
     
    107107Note in particular the `LEFT OUTER JOIN` statement here.
    108108
     109=== Updating the database ===
     110
     111As 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:
     112
     113{{{
     114#!sql
     115INSERT INTO ticket_custom
     116   (ticket, name, value)
     117   SELECT
     118      id AS ticket,
     119      'request_source' AS name,
     120      'None' AS value
     121   FROM ticket
     122   WHERE id NOT IN (
     123      SELECT ticket FROM ticket_custom
     124   );
     125}}}
     126
     127If 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:
     128
     129{{{
     130#!sql
     131INSERT INTO ticket_custom
     132   (ticket, name, value)
     133   SELECT
     134      id AS ticket,
     135      'request_source' AS name,
     136      'None' AS value
     137   FROM ticket
     138   WHERE id NOT IN (
     139      SELECT ticket FROM ticket_custom WHERE name = 'request_source'
     140   );
     141}}}
     142
    109143----
    110144See also: TracTickets, TracIni