Symfony2价格输入和显示

I've created form in Symfony2 with number field using FormBuilder:

$builder->add('price', 'number');

Field is only properly processing numbers with "," (comma) used as decimal separator (per locale setting), but I want it to also parse numbers with "." (dot) used as decimal separator. Right now digits after "." (dot) are ignored.

What should I do to process both prices with both types of decimal separators?

Have a look at this component, though I don't know how it renders.

Anyway you may try with a custom Regex validator constraint, asking for something like number + dotOrComma + number.

Or to sell your goods for free without price tag.

You'd need to create a custom type, using the code of the core type as reference point.

See this open feature request for reference.