This patch implements formatters for specified number of decimal places and significant figures. It depends on #580540: Implement rounding to significant figures for format_number.module for the significant figures algorithm.

By default it enables formatters for DPs of 0, 1 and 2, and SFs of 1, 2, 3 and 4. However these are overridable by setting Drupal variable or through $conf in the settings.php file. However there is no UI to change them in this patch.

A screenshot showing the additional formatters is attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
Status: Needs review » Needs work

Unfortunately, there's no place in CCK to provide settings for field formatters, and now I'm using the number of decimals defined for the field. There's also a "Remove redundant zeros" formatter. I would not change this, but add only new formatters for the new significant figures format.

Bevan’s picture

Status: Needs work » Needs review

I don't understand your concerns or why you put this to "needs work". Did you review it? I'm confused.

Bevan’s picture

Perhaps you meant settings for the range of lengths that the module creates formatters for? There is no need for per-formatter settings. That's what these settings are for. They are site-wide Drupal variables that say what formatters to enable. E.g. the default for DP is 0,1,2. So there are three DP formatters, "0 decimal places", "1 decimal places" and "2 decimal places". If the setting was changed to 1,2,6 it would provide formatters for 1 dp, 2 dp and 6 dp.

There is no UI for these settings, but it would be logical to put one on the admin/settings page for the module. IMO the UI should be addressed separately in a different patch. Since this is something that users would rarely need to configure, and already has sensible defaults. Also because the UI, form widgets, UI text and implications of deleting a formatter need considerable thought in order for it to be usable.

markus_petrux’s picture

Title: Formatters for significant figures and DP » Additional formatters for fixed number of decimal places and significant figures
Status: Needs review » Fixed

Committed a slight different version to CVS (commit).

Differences:
- There's no additional formatter by default. You should add lines to your settings.php file. Described in the README as well as the project page.
- The new theme function also respects prefix and suffix options defined in field settings form.
- Using format_plural() to build the formatter labels.

Thanks!

Bevan’s picture

Great! Thanks! :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.