0

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.

3

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.

enter image description here

5
  • 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?
    – learn4ever
    Jun 4 '15 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
    – No Sssweat
    Jun 4 '15 at 19:28
  • @Drupol did this work for you?
    – No Sssweat
    Jun 7 '15 at 1:07
  • 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?
    – learn4ever
    Jun 8 '15 at 20:52
  • That's because you need to change it from space to comma (see above picture) in your view's field.
    – No Sssweat
    Jun 9 '15 at 2:57
1

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.