Hi! I'm trying to format a price number to get the text field look like "4 200 000" in the frontend.
I try to use the custom sanitize callback as you mentioned here
I added formatage_prix in the callback field of my price text field and this code:
<?php
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
$meta_boxes[] = [
'title' => 'formatage_prix',
'fields' => [
[
'type' => 'text',
'id' => 'prix_vente_bien',
'name' => 'Prix de vente',
'sanitize_callback' => 'formatage_prix',
]
],
];
return $meta_boxes;
} );
function formatage_prix( $value, $field, $old_value, $object_id ) {
$number = rwmb_meta( 'prix_vente_bien' );
// French notation
$nombre_format_francais = number_format( $number, 2, ',', ' ' );
echo $nombre_format_francais;
}
It doesn't work. Would you be able to help me figure that out? THanks a lot and happy new year!