HTML5 Form Elements

Events happening in the community are now at Drupal community events on www.drupal.org.
greenskin's picture

Is there a module that provides HTML5 available form element types? For example the type 'email' and type 'tel'.

Comments

Theme

mikeytown2's picture

It would be in the theme layer. Head start
http://drupal.org/project/themes?text=html5

I'm looking for a module to

greenskin's picture

I'm looking for a module to provide the appropriate element type, not specific to the theme layer. This way a module when building a form can simply use '#type' => 'email' to create a textfield element with type 'email'.

CCK? Form API?

sreynen's picture

There's a lot of form elements that are created by themes, but also a lot of default markup generated by modules. It would be nice if themes didn't need to constantly override the latter. I've thought about doing this for CCK widgets, but it sounds like maybe you're talking more about fields created by modules Form API?

Yes, I'm referring to having

greenskin's picture

Yes, I'm referring to having a module that implements the various form elements via the Form API. The concern is more or less for mobile browsers like on iPhone or Android. They recognize a textfield of type 'email' rather than simply type 'text' and when the virtual keyboard is loaded, an '@' symbol is made available without the user having to switch to the alternate keyboard. Same thing for type 'tel' except the keyboard defaults to the version with the numbers on it.

The reason I think this should be a separate module is that a module that creates a form should control whether a textfield should be type 'email' rather than type 'text'. A theme has no way of determining what type to render the textfield as. It is a possibility to form a standard flag that modules can pass to textfield elements and then themes can override the theme_textfield and render out the type appropriately. But this would need to become a standard of sorts among modules and themes.

Or back to my original idea is another contrib module implements a #type => 'email' element (among others) for the Form API and modules can check if the module exists and use the alternate type instead of simply 'textfield'. Then everything out of the box would work. Also, the contrib module can do a simple check if the browser is the iPhone's safari or Android's browser and only display type 'email' for those browsers else fallback to type 'text'.

I'd help

sreynen's picture

I'd be happy to help with something like this, assuming it's possible. I know nothing about adding new field types to Form API via modules. I think browser sniffing has been pretty well established as a bad thing, and I also don't see any need for it here as type="email" works just like type="text" in all browsers that don't understand it. So I'd be against that.

This would probably good to

dave reid's picture

This would probably good to go in the Elements module where we can test and provide elements to Drupal 6/7 and hopefully up-port to core.

Senior Drupal Developer for Lullabot | www.davereid.net | @davereid

Contributed Module Ideas

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: