Once you create a text in a Select list option and you enter in the allowed values field the format key|label, it shows in the select list the label, but it doesn't show the selected key in the code generated after select an option. It seams like it stores only the label in the database.

I will try to explain further. I think it should work like if I write:
peter|pann
the option in the select list showing will be pann but once I clicked the button save when creating new content I expect it writes the peter text and not pann again, now it is showing pann in the list option and also it is showing pann in the text created in the content page.

Is this a bug?

Comments

coltrane’s picture

Status: Active » Closed (works as designed)

It works as designed. The label is always displayed outwardly, but the key is stored in the database and used in the node object. This is useful if you wanted a really long label but a shorter key used internally by other modules for example.

If you want peter to show after creating a node then you could not set pann as the label for the field. peter will also show in the select option though.

nadid’s picture

Oh, look's like you are right, sorry. I guess then the problem is not from this module, and probably is from cck blocks module, I will ask there because it is showing the label and not the key in the output, maybe is also by design, but better ask.

Thank you :)

nadid’s picture

Category: bug » support
Status: Closed (works as designed) » Active

Hi,

As I reported here the cck block is doing something weird because it shows the label and not the key when the label in default values is selected. Maybe it is by design also but I would like it behavies diferently, and thats why I've openned this support request.
As you can see in the next issue, im trying to do something to solve make it do what i want it to do.
#264726: Rare behaviour when key|label is set.

The problem is I dont understand why the next line is showing the label and never the key differently as cck does.

$block['content'] .= module_invoke('content', 'format', $fields[$delta], $item, $settings['formatter'], $node);

I have what I want to show in the $item['value'](the key) var. And I can use it straigth. And it seams like the before code likes to show the label.

Can anybody explain to me what I should do to show the $item['value'] when it is deffined and when it's not show the

If I do

 $block['content'] .= module_invoke('content', 'format', $fields[$delta], $item['value'], $settings['formatter'], $node);
 

it shows an &.

Thank you.

nadid’s picture

Status: Active » Closed (fixed)

Hi, I close this support request because I just understood what was happening,

As coltrane said it shows the label always if it is defined, so, if I want to show the key i must get it from the database.

Maybe the node object is using the key, but it shows the label.

I think what maked me to missunderstand was the sentence:

"but the key is stored in the database and used in the node object"

I thought it is used and showed but it must be something like used internally, and it isn't showed at all.

Thanks for the help