I have a couple of numeric custom fields - such as price and mileage. They are numeric fields.
I would like to have them displayed with proper formatting such as 95,000 for mileage and $ 25,000 for price. I can't see a way to do this. I saw one response from someone else trying to do this and the suggestion was to create a shortcode or something in functions.php. I'd rather avoid that if possible.
When I go through the wizard to add a numeric field, it offers to provide a "format" attribute and gives a value of "FIELD_NAME: FIELD_VALUE". This implies that there might be other values I could put int he format attribute to format the number but I don't see any documentation on this.
There is no "automatic" way to do this.
A numeric field is in its nature numeric, hence it will allow only numbers and dots.
What you'd have to do to format miles, prices, and other numeric data differently (it will also differ by country) is to create a single line field and enter the data as it should appear (with a comma, dot, or another separator).
Unfortunately, it is not possible to filter this elsehow with Toolset
Also, remember that you might need to use this in a filter, so having characters in there that are not numeric can lead to issues.
Better would be, to use the number field as is, always dot-separated, and add the unit in a second field or manually when inserting the value.
The format you refer to are only meant to control what's output for the field and its value - but there is no way to automatically intercept the type of value and convert that adequately.
Thanks for the reply. It's unfortunate that you have a "format" option on the data but you don't really have any format characters to use with it. It looks like all you have are "FIELD_NAME" and FIELD_VALUE. Why not allow format characters - the printf characters that you find in other format templates - i.e. ##,###.## or whatever.
Your suggestion to just make this a text field has its own problems. People would then be able to enter the value in any way they want - with commas, without, with additional text, etc. Like you said, if it's a number make it a number. It's on the display side that we need options for formatting those numbers.
Anyway, I think I found a solution for this. It requires creating a shortcode but you guys have the Custom Code tab in Settings along with your documentation about it that makes this pretty simple.
Thanks.
I'd suggest asking for the feature here https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
It is likely a complex implementation because there are many possible formats to follow, but if there are many users requesting this, our Product Management can consider such requests.