Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

#6755 closed defect (duplicate)

[PATCH] Empty default value in custom field

Reported by: anonymous Owned by: Christopher Lenz
Priority: normal Milestone:
Component: ticket system Version: 0.11b1
Severity: normal Keywords: patch custom default
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

It is not possible to configure a custom field to have an empty default value.

http://trac.edgewall.org/wiki/TracTicketsCustomFields notes: "To make entering an option for a select type field optional, specify a leading | in the fieldname.options option."

excerpt from trac.ini

buggyCustomField = select
buggyCustomField.label = Empty Default
buggyCustomField.options = |foo|bar
buggyCustomField.value = 0

With this configuration, the actual default value shown is 'foo' instead of the desired empty default value. (The only workaround is to specify an unreasonably large buggyCustomField.value and to live with the resulting warning in the Trac log.)

Please find attached a one-line patch, which resolves the defect. (Caught out by Python shorthand … ;-) It would be great if this fix would make it into the 0.11 release. Thanks, and keep up the good work!

Email withheld due to concerns over spam — will keep monitoring this ticket.

Attachments (1)

custom-field-empty-default.diff (593 bytes ) - added by anonymous 16 years ago.

Download all attachments as: .zip

Change History (3)

by anonymous, 16 years ago

comment:1 by mark.m.mcmahon@…, 16 years ago

If you leaving out

buggyCustomField.value = 0

then it works.

in reply to:  description comment:2 by osimons, 16 years ago

Milestone: 0.11
Resolution: duplicate
Status: newclosed

Replying to anonymous:

With this configuration, the actual default value shown is 'foo' instead of the desired empty default value.

As it actually states in the docs for select type fields it says: "value: Default value (one of the values from options)." 0 is not a recognized option in your list. If you want to set empty to be the default then either don't specify it (as you found out), or set it as an empty value (emtpy actually being the first of the options):

notBuggyCustomField.options = |foo|bar
notBuggyCustomField.value = 

Select is name-based, radio is index-based. If in select you want to make bar default, you use bar and not the index value (2).

Anyway, this is a duplicate of now fixed #5451.

BTW, if you think the docs and examples can be even clearer, then by all means help by editing the wiki directly.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.