This module allows you to format numerical fields (decimal, float, integer) using `sprintf` formatting strings. It's useful for tasks like generating entity labels that require numbers to be padded with leading zeroes or displayed in a specific decimal format.
This module adds a dynamic "Formatted" token for decimal, float, and integer fields that allows the use of a sprintf formatting string to format the number.
Note that this is a simple application of the function using a single value:
sprintf($your_format_string, $numeric_field_value);
A formatting string that expects multiple values will produce no output.
Use case
We had a need for this functionality when we needed to generate automatic entity labels for nodes that included a number field, and needed that number padded with leading zeroes in the labels.
Depends on
Dependencies of the latest stable release
- field Drupal core
- system Drupal core >= 10.0
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 2.3.0 | Stable | 10–11 | Mar 27, 2025 |