Jump to content

format number in admin

Recommended Posts

Hello and thank you for the great job that all of you do every day on this great project!!!


I have a little question:

is possible to format the field float or decimal in this way: from 1000000.56 to 1.000.000,56 in repeater and repeater matrix?


Thank you very much




Share this post

Link to post
Share on other sites

Just for display in the repeater label? That can be done with a little hook in site/ready.php:

wire()->addHookAfter('InputfieldRepeater::renderRepeaterLabel', function (HookEvent $e) {
	$label = $e->return;
	$page = $e->arguments('page');
	$label = preg_replace_callback('/\\[([a-zA-Z0-9_]+)\\]/', function($match) use($page) {
		return number_format($page->{$match[1]}, 2, ',', '.');
	}, $label);
	$e->return = $label;

This looks for a field name between square brackets (something like "[price]" in "#n: {title} - {item} - [price]") in the label and replaces it with the formatted value of that field.

  • Like 8

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...