Missing 10,000 foot understanding of what HTML5_Tools provides with Forms API

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

I put together the beginnings of a module with a form using the Forms API. It had nested fieldsets and looked pretty good with the default Bartik theme. When I saw the HTML5 support for email, tel and number fields, I tried to use them by installing elements module and then the html5_tools module, and finally the Omega theme. I am assuming Omega is needed for HTML5 support, although I have not seen any specific mention of it.

The problem is that all the fields in which I specified HTML5 field types stopped being displayed. The following was drawn from this URL: https://www.drupal.org/node/1315186

$form['Contact']['Email'] = array(
'#title' => t('Email'),
'#type' => 'email',
'#required' => TRUE,
'#placeholder' => 'john.doe@example.com',
'#description' => t('Email of the person requesting the proposal and quote.'),
);

But then I saw this issue:

https://www.drupal.org/node/949970
https://www.drupal.org/node/970068

However, it seems to be based on the email.module, which I did try at one point, but then switched to elements/html5_tools. However, another person created an issue about "HTML 5 email field via Elements Module": https://www.drupal.org/node/2500865

Why would he have to create a patch if this functionality is already in the HTML5_Tools module?

A sample project would be great, but even know which modules I am supposed to be using to get my code to work would be very helpful. Thank you!

Fred

Comments

Figured out the magic sauce!

fbrier's picture

Never give up! Never say die!

So I found a patch file for the "tel" HTML5 field and found out that the #type is supposed to be "telfield". Extrapolating, I tried "emailfield" and "numberfield" and all started working.

https://www.drupal.org/files/issues/1036704-telephone_field-6.patch

It seems strange that I could not find a single web page with a cheat sheet showing the corresponding Forms API #type names for the HTML5 fields. Thank you for writing this module. Onward to my next feature!

Fred

HTML5

Group notifications

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