I'm working with Symfony 3.4 and I'm trying to apply mask for my MoneyType | NumberType field,
The purpose of the mask is to act in the Front to make :
1) Format the number (obligatory):
12000.5 => 12 000.5
1234567.2 => 1 234 567.2
2) Disable non numeric Field (optionally):
When the user try to tap a character, the input never change.
For that I try to work with JQuery Libraries, but I get an issue when submitting the form, the backend considers that the input is not a number so the $form->isValid() is not satisfied
FormType:
->add('prixUnit', NumberType::class, array(
"grouping" => true, //works only on show mode not on newAction
'attr' => array(
"class" => "number"
"min" => 0,
"step" => 0.100,
"placeholder" => "0.000",
)
))
Twig:
$('.number').maskSomeLibrariesJquery();
I'm searching for a clean Symfony Solution to format my field without having problems in the backend.