Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.9
Component:
number.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Apr 2011 at 21:03 UTC
Updated:
10 Aug 2011 at 08:42 UTC
Greetings,
I have a CCK integer field that must be a minimum of 6 characters. Some figures that will go into this field are less than 6 characters, so we are putting zeros in front as needed to make the number 6 characters.
For example, the number 329 becomes 000329.
The problem I'm running into is that because it is type integer, the leading zeros are being trimmed by default and therefore the number shows as 329 rather than 0003329.
Does anyone have any insight into how to remedy this so that the leading zeros are not trimmed?
Thanks in advance.
Scott
Comments
Comment #1
Rix-1 commented+1
Comment #2
cholden commentedI'm desperate to find a solution to this issue as well. I could use a normal text field to get the zeros right, but I need the way the integer sorts in views.
Comment #3
karens commentedAn integer field is stored as an integer, you can't make it into something different. If you want leading zeros it is not an integer, it is probably a text field. If you have stored it with leading zeros, it should sort correctly as a text field.
Comment #4
cholden commentedI solved it with the text field as you suggested. But it didn't sort as the integer field did. I solved the sorting problem by adding a Computed Field which converts the value of the text field as an integer. I used this as the sort field in views. Works perfect.
Here's my computed code for the Computed CCK field:
$node_field[0]['value'] = (int)($node->field_productstyle[0]['value']);
…and the Display Format:
$display = $node_field_item['value'];