Part of the Token ecosystem · 21 projects
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.
Ask your assistant about token_number_sprintf
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
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.
More in the Token ecosystem
Most installed first