Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Autofilling leading zeros?

Quote Reply
Autofilling leading zeros?
Hi,

id do have a numeric field (int) with values from 0 up to 99999 - any idea how to add leading zeros until 5 digits if the data is lower than 10000?

Thanks for your hints!
Quote Reply
Re: [TB2] Autofilling leading zeros? In reply to
Hi,

Use a global. If your field is called 'Foo', use:

leadingzero_foo =>
Code:
sub { return sprintf ("%05d", $_[0]->{Foo}); }

and then just use <%leadingzero_foo%> in your template.

Cheers,

Alex
--
Gossamer Threads Inc.