Support for HTML5 Input Types in FormHelper
Reported by Conrad Akier | April 18th, 2010 @ 04:41 AM | in 2.0.0 (closed)
Problem
FormHelper currently inserts a textarea whenever an input type not covered by its switch cases is passed to it. This includes the new HTML5 input types such as 'email,' covered here:
http://diveintohtml5.org/forms.html
For example,
$form->input('email', array('type' => 'email'));
outputs a textarea field. I expected to see something like this:
<input type="email" />
Proposed Solution
- Change the default case to generate an input tag with the type
defined in the options array rather than a textarea. Browsers treat
any tag with an unknown type as a regular text input box.
- Add specific support for HTML5 types.
True, HTML5 is still in draft, so you could argue that HTML5 support isn't appropriate yet. Regardless, if you're calling input() with a type specified in the options array, wouldn't you expect an input with type="specified-type" rather than a textarea?
Comments and changes to this ticket
-

ADmad April 18th, 2010 @ 12:33 PM
- → Milestone set to Future
- → Tag changed from formhelper, html5 to enhancement, formhelper, html5
-

Si Jobling April 20th, 2010 @ 02:51 AM
I'd love to start using HTML5 on my CakePHP projects, especially with Safari Mobile supporting it on the iPhone, so the sooner this integration is in place, the better.
-

ADmad April 20th, 2010 @ 02:55 AM
And what we would love to see is patches for new features people want :)
-

Mark Story April 20th, 2010 @ 09:21 PM
Its always good to keep in mind that CakePHP is made of people volunteering their time. Contributing patches/test back that implement the things you want to see implemented is a good way to help improve the project. Right now 1.3 is feature frozen, but this is something that could be considered for a future release :)
-

Conrad Akier April 21st, 2010 @ 12:06 AM
Eek! I didn't think that creating this ticket would bring about such a reaction, although I imagine that has more to do with the comment that came afterwards.
Mark/ADmad, I really appreciate the effort, time and touch you've contributed to this project. I almost didn't create this ticket because I didn't have time to create and attach a patch as I like to do, but I figured it would be helpful to bring the issue to light. When work calms down for me, I hope to have a patch for this if no one else beats me to it.
Thanks!
-Conrad -

Mark Story April 21st, 2010 @ 09:05 PM
Conrad: No worries, I think just submitting a ticket is a fine, I understand that people are busy and time is short for everyone. HTML5 support is something I too would like to see in the future, so it will eventually get done. I figured if people want it faster they can always help out :)
-

Quentin Hill June 7th, 2010 @ 07:49 PM
Here's a modified version of the form helper with the following enhancements:
- Support for HTML5
url,email,number,rangeandsearchform elements. - Input elements of an unrecognized type are made into
<input>tags, instead of<textarea>.
This should be a drop in replacement for the built-in form helper, and I've tried to keep up with the documentation comments.
Is this the right place for this? If not, please point me in the right direction on submitting this to the proper channels.
- Support for HTML5
-

Mark Story June 7th, 2010 @ 09:19 PM
A drop in replacement is a good first step, diffs against the existing file are also good as they are more portable towards future versions. And this is the right place to post such things :)
-

Quentin Hill June 8th, 2010 @ 11:23 AM
This is my first real foray into the open source world, so thanks for the help!
I went ahead and made a diff from the stock Cake 1.3.2 form.php and my custom one I posted above. I just ran the two through the
diffcommand, and am attaching the file. Hope it meets what you guys are looking for. -

Mark Story July 29th, 2010 @ 09:48 PM
- → Milestone changed from Future to 2.0.0
Moving to 2.0 as I think that is a good time to address this. Thanks for creating the patch Quentin.
-

Mark Story August 16th, 2010 @ 09:31 PM
- → Assigned user set to Mark Story
-

Mark Story August 16th, 2010 @ 11:19 PM
- → State changed from new to resolved
Thanks for the diff, it helped in figuring out how to address the problem. I didn't implement the various separate html5 form methods. Instead I used a __call to handle them all. See [e79df234919c27727d750ebb022acdfa04a3dbc0] and [750fe3aa052957e9f0e834a6508d98bdaef6feba].
Since all the html5 current and future types are done, I'm closing this ticket :)
-

thatcode August 17th, 2010 @ 07:21 AM
Hi.
Was looking through code for cool new features, found a tiny error with this commit:
Line 1135
throw new Exception(sprintf(__('Missing field name for FormHelper::%'), $method));Missing the s of %s in the sprintf, meaning the method name is not attached.
Should be:
throw new Exception(sprintf(__('Missing field name for FormHelper::%s'), $method));Thatcode
-

Mark Story August 17th, 2010 @ 09:26 PM
Thanks for finding that, fixed in [6d8c761f2f81d5a239beda6b8957b6ff551c9d45]
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
Repository is at http://github.com/cakephp/cakephp
Creating a bug report
When creating a bug report, please include as much relevant information as possible. Please include code to reproduce the issue. Or even better, make a unit test. Either change an existing test or add a new test to show that the expected behavior is not occuring.
People watching this ticket
Attachments
Tags
Referenced by
-
#1063 Support for custom meta tag elements in HtmlHelper
There was a similar solution discussed with creating cust...
-
#1388 Form->input( type="ranger" ) should not generate a textarea
Duplicate of #598