I have a text field. View select the text field. I entered three numeric values to the text field as 3321,33432 and 110343. In the view, I see the values without the commas. I like to see these numbers as 3,321, 33,432 and 110,343. Is there way I can rewrite the output using comma? Please provide some help.
2 Answers
What type of text field did you choose for your field? Regular text field?
If you want to be able to add comas. When you add a new field to your content type you need to select INTEGER as your field type, not text.
Then View's will detect that its an integer field (numbers only) and give you the comma option.
-
I allow max 6 digits number. When I selected Integer, I did not see the option to enter 6 as limit. Thats why I chose text field where I can enter 6 as limit. Do i have to create new integer field or I can just edit the text field type to integer? Also, how I can set the limit to 6 digits if the data type is integer?– autopCommented Jun 4, 2015 at 18:22
-
1@Drupol you have to create a new integer field, unfortunately Drupal doesn't allow to change field type once it's created. The Integer field does give you a maximum value option. So put 999999 as the max, which would be the equivalent of a 6 digit limit Commented Jun 4, 2015 at 19:28
-
-
It gives me empty space not the comma. Ex- If I enter 22343, it displays as 22 343. How can I display it as 22,343 instead?– autopCommented Jun 8, 2015 at 20:52
-
That's because you need to change it from space to comma (see above picture) in your view's field. Commented Jun 9, 2015 at 2:57
It is a PHP question, if the number is $num
and you need no decimal point write
number_format($num,0,'.',',');
No matter what the field is, this code inserts thousands separator, you can use this in Rewrite Results
textarea. more information in PHP Number Format.
You can also install currency module