boltforms icon indicating copy to clipboard operation
boltforms copied to clipboard

Error with form field type tel

Open Chazz09 opened this issue 8 years ago • 2 comments

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?

Chazz09 avatar Sep 15 '17 12:09 Chazz09

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.

rossriley avatar Sep 15 '17 17:09 rossriley

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?

Chazz09 avatar Sep 18 '17 14:09 Chazz09