Formatting MODX number TVs in the Manager

I just noticed that there seems to be no way to make MODX template variables display numbers always with two decimal places for editing in the Manager. You can turn on “Allow Decimals” and set the Decimal Precision to “2”, but if you then type in a number like “12.00”, the zeros and period get stripped and it changes to just “12”. And “12.20” gets changed to “12.2”. That’s not so great when a field is meant to contain prices. Also, there is no way to right-align numbers.

Is there any way to do this?

You could use a custom output modifier:

return number_format($input,2);

I’m talking about in the Manager itself, when you are entering numbers into a TV field. I’ve updated the title and description here to try to make that clearer.

Maybe you can use a normal Text TV with a “Regular Expression Validator” like ^\\d+\\.\\d{2}$.