Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.x-dev
Component:
General
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 May 2009 at 06:43 UTC
Updated:
31 May 2009 at 08:37 UTC
Could I create a field, the value in database in number, but there is a mapping for text to show on screen? For example, I have a field to record the "status", the possible value is "active", "closed", "duplicated", "fixed". I can use a text field, but if I use text field, when I want to change the value (i.e change "fixed" to "resolved"), I need to modify the database manually.
Therefore, is it possible to create a number field, the value is 1,2,3,4,5, ... and I can configure a mapping for 1=active, 2=closed, 3=duplicated, 4=fixed, .....
Comments
Comment #1
markus_petrux commentedYou can use optionwidgets with a number field (that's a number field with radios/checkboxes or select lists widgets). And in the allowed values list you build the mapping like this:
The values on left of the character | is the value stored in database, and the value on the right is the label used to display the value in the form widget and when the node is displayed.
At any time you can change the labels, or even add more values:
You can use optionwidgets with fields of type text or number, depending on the value you really need to store in the database. The label is always controlled by the right side value on the allowed values list.
Comment #2
dennys commentedThanks, it works. CCK is great !!