Leading Zeros Formatter

Component ID

2926235

Component name

Leading Zeros Formatter

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

9

Component created

Component changed

Component body

Introduction

The Leading Zeros Field Formatter extends the Integer Formatter to add leading zeros to integer fields. Settings for Thousand marker and Prefix / Suffix can also be configured. This may be useful for printing product ids, serial numbers or similar that need to conform to a certain pattern in display.

Requirements

This module requires no additional contrib modules, just the core field module, and an integer field.

Configuration

Just install and use the formatter for any integer number field and set the Minimum length of the formatted output of the number.

The maximum length of the integer field is 10 digits, nonetheless you can set a value of up to 19 for the formatter, to 'simulate' longer values for visual reasons (just filled with zeros, of course).

Example

With Minimum length set to '8', integer '12345' is padded with leading zeros, and printed as '00012345'. The thousand marker is respected, and for example rendered as '00.012.345'.