I created a new cck field with the following parameters:
fieldtype: number_integer (its the same with fieldtype text)
widgettype: select list
allowed value list
1|0
2|1
3|½
4|+
5|-
The first two lines are shown as "1" and "2" instead of "0" and "1" (in select list and node)
so I think the Key is shown instead the label
Is it possible to use 0 and 1 as a label ?
I need it to display results of chess tournaments

CommentFileSizeAuthor
#2 281749.patch798 bytesasimmonds

Comments

Micha1111’s picture

No solution ?

asimmonds’s picture

Component: CCK in core » content.module
Assigned: Micha1111 » Unassigned
Status: Active » Needs review
StatusFileSize
new798 bytes

Taking the example allowed values list above, produces a $options array of:

Array
(
    [1] => 1
    [2] => 1
    [3] => ½
    [4] => +
    [5] => -
)

notice that for the first pair, the key is used for the label instead of the requested "0", it should be:

Array
(
    [1] => 0
    [2] => 1
    [3] => ½
    [4] => +
    [5] => -
)

When the allowed values list is parsed, the "0" value is being ignored because a (bool) test of "0" is false

$allowed_values[$field['field_name']][$key] = $value ? $value : $key;

The attached patch adds a isset() and a test for a empty string (in-case a allowed values line reads something like "2|" instead of "2|1")

yched’s picture

Status: Needs review » Fixed

Committed to D5 and D6 branches. Thanks !

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.