I am trying to use the type validation rule with integer and it fails with some warning.
Here is my form
class BusinessType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('business_number', 'integer', array(
'required' => false,
));
}
}
Here is my validation rule
My\Bundle\Entity\Business:
properties:
business_number:
- Type:
type: integer
So nothing extravagant!
But I get the following error
Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Warning: NumberFormatter::parse(): Number parsing failed"
I already found a work around here, but it doesn't feel right to do that. I will if there is no other solution but I prefer to avoid it.
I know it was a known bug in earlier version of Symfony but it is supposed to be fix. See here.
So is there a way I can use the type validation? And if so, what am I missing?
Edit 1
I am using Symfony 2.6.6
Edit 2
If my value starts with numbers (like 123dd), I have the following error message, even if I customized my error message
This value is not valid.
But if my value starts with something else, I have the error fore-mentioned.
Edit 3
The longest value I need to store is 9 digits long. So integer should work properly.
Edit 4
Here is the bug report
telinput type.business_numberblank?numberForm Type, not theintegerone, although theIntegerToLocalizedStringTransformerextends theNumberToLocalizedStringTransformer. Could you try using anumberForm Type instead?