When I try to change the configuration of the thousands separator for numbers, it does not work as expected.

The default thousands separator is a space. I have a field of type type integer named field_assignment_hours in a "job" content type. I changed the configuration to use a comma rather than a space by going to admin/structure/types/manage/job/display. However, even after changing the configuration I still get a space instead of a comma when I try to create formatted output by invoking the following function:

field_view_field('node', $job, 'field_assignment_hours')

Comments

pillarsdotnet’s picture

kay_v’s picture

Hi -

Two of us in the Boston Drupal Meetup group tried to reproduce the issue you describe, and noticed the following:
1- the thousands separator displays correctly in an 'out of the box' node display (see note below on our setup)
2- we were not able to get the function you wrote to display when we included it in template.php; we got errors - can you give a context for your function?

What we did:
attempt 1
- launched fresh install of Drupal 7.8
- tested first with basic page content type
- created field with machine name field_assignment_hours
- changed display setting for thousands separator to comma
- rendered node => everything normal
attempt 2
- created content type 'job'
- created field with machine name field_assignment_hours
- changed display setting for thousands separator to comma
- rendered node => everything normal
- referred to field_view_field in api to confirm usage
- added your function to bartik's template.php in various places, but didn't get anything to render; we're not familiar with the arguments you supplied. More information would help reproduce the issue.

What information might help?
- indicate where you put the function (file name and type and perhaps whether your function is inside another function)
- the source of the $job variable (we noticed it matches your content type - coincidence?)

pillarsdotnet’s picture

sheldon rampton’s picture

Thanks for your detailed review. I'm currently very busy on a client project but will post a response to some of your questions in a few days (maybe this weekend). If need be, I can supply a complete copy of my Drupal codebase for your review.

yched’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

The code mentioned in the OP (field_view_field('node', $job, 'field_assignment_hours')) has no $display argument (see API page for field_view_field()).

This means the field will be displayed using the default formatter with the default settings (which for D7 means ' ' as a thousands separator), independently of whatever you may configure on the "Display fields" pages.

sheldon rampton’s picture

Upon further review, I think yched is right and this was a code error on my end.

sheldon rampton’s picture

Issue summary: View changes

Corrected what I am sure was an unintentional typographical error.