Error with form field type tel
Form field type: tel does not work.
This:
phone:
type: tel
Results in an exception: "An exception has been thrown during the rendering of a template ("Could not load type "tel"")"
Just to be sure I'm trying to achieve:
<input type="tel">
How can I get this to work?
Unfortunately at the moment Symfony Forms doesn't support a telephone number type, the closest you can get is:
phone:
type: number
I have a feeling it's not customisable via the config but the way to customise attributes is via the attr config like this:
phone:
type: number
attr:
type: tel
If that doesn't work then you would need to tweak the form template to show a different widget based on a class or data attribute.
Ok changing it in the config unfortunately doesn't work by adding attr: type: tel.
In the form template I also tried adding it as a attribute, like this:
<span class="boltforms-value">{{ form_widget(form[key], { 'attr': {'type': 'tel'} } ) }}</span>
But this doesn't change anything also. Any suggestions on how to add this in to the form template?