Opened 17 years ago
Closed 17 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)
Change History (3)
by , 17 years ago
Attachment: | custom-field-empty-default.diff added |
---|
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Milestone: | 0.11 |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
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.
If you leaving out
then it works.