Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
New types: email, url, number, range, etc
Comment | File | Size | Author |
---|---|---|---|
#14 | 816090-elements-html5.patch | 8.09 KB | Dave Reid |
#13 | 816090-elements-html5.patch | 8.5 KB | Dave Reid |
#9 | html5_1.patch | 10.05 KB | bleen |
#8 | html5.patch | 10.08 KB | ericduran |
#5 | html5.patch | 9.23 KB | ericduran |
Comments
Comment #1
ericduran CreditAttribution: ericduran commentedHi,
Here's a patch that adds support for email, number, range, search, and telephone field. I also added support for the placeholder text on the new field.
I don't think is complete there's still some fields and properties missing but I think is a good start.
Quick Documents on creating the New fields:
You can also control how invalid fields are display using css with the dynamic pseudo-class ':invalid'.
Comment #2
ericduran CreditAttribution: ericduran commentedOh Also here's a quick screenshot on how these form elements display on Chrome.
Comment #3
casaswing CreditAttribution: casaswing commentedSubscribe
Comment #4
shawn.sh CreditAttribution: shawn.sh commentedI like the idea of having some level of support for html5 form elements. Hope we get this in soon.
Comment #5
ericduran CreditAttribution: ericduran commentedHere's an updated patch. I got rid of the placeholder attributes since it can be implemented with the form api attributes key.
I also added the url element and simplified all the element's type name.
Comment #6
ericduran CreditAttribution: ericduran commentedJust assigning to myself.
Comment #7
bleen CreditAttribution: bleen commentedsubscribing
Comment #8
ericduran CreditAttribution: ericduran commentedHey,
Here's an updated patch that provide support for the placeholder attribute as per our conversation on irc. Since the html5 spec allows the placeholder attribute to go in the text and password field I added it to both. And of course the new elements :-D.
One thing to note. I kinda got lazy and just added the process callback to the new elements. That's actually not necessary for the new elements since we're the one's implementing the theme function for those elements. We can actually implement the placeholder attribute in the theme function but I decided to be consistent instead. If anyone thinks I should change it just let me know and I will.
Comment #9
bleen CreditAttribution: bleen commentedThere were a few whitespace issues that this patch addresses ... but other than that I think this looks pretty clean.
Comment #10
voxpelli CreditAttribution: voxpelli commentedsubscribe
Comment #11
jensimmons CreditAttribution: jensimmons commentedsub
Comment #12
LSU_JBob CreditAttribution: LSU_JBob commentedsubscr
Comment #13
Dave ReidRevised patch that simplifies and re-uses some functions when theming the elements.
Comment #14
Dave ReidWithout the changes to the imagebutton field...
Comment #15
Dave ReidPlayed with the latest patch a lot and replacing core fields with HTML5 elements with Chrome. Everything worked fine, so I'm committing to CVS!
http://drupal.org/cvs?commit=403074
Comment #16
Dave ReidBTW feel free to follow-up with any patches if necessary.
Comment #17
jcmarco CreditAttribution: jcmarco commentedLast patch breaks Drupal if you are using CCK (almost mandatory) with the module Number:
Fatal error: Cannot redeclare theme_number() (previously declared in xxxxx\sites\all\modules\cck\modules\number\number.module:583) in xxxxxxxxxxxx\sites\all\modules\elements\elements.module on line 245
So probably it would be needed to change the theme function names to avoid conflicts.
Comment #18
ericduran CreditAttribution: ericduran commentedYea, it does break cck. We had change the number field to numberfield so it can play nice with cck. But it must had gotten lost in the follow up patches. I'll submit and update patch reverting back to numberfield
Comment #19
Dave ReidAh, that wasn't noted inline on the original patches why it had to be named 'numberfield'. Fixed in CVS with http://drupal.org/cvs?commit=403808.
Comment #20
Dave ReidI just did a search through contrib to find any more conflicts:
theme_search() - not found
theme_range() - already taken by http://drupal.org/project/range
theme_tel() - not found
theme_url() - not found
theme_email() - not found
Do we want to standardize on using [item]field (e.g. telfield, urlfield) as the FAPI types for consistency?
Comment #21
ericduran CreditAttribution: ericduran commentedYea, We probably should use [type]field. I had done that in my 1st patch then back out of it :-/.
Comment #22
voxpelli CreditAttribution: voxpelli commentedJust a thought: Not considering that one field has already been named [type]field - wouldn't it be more suitable to name the fields [type]element, considering that this module's name is "Elements" and not "Fields" or something like that?
Comment #23
ericduran CreditAttribution: ericduran commentedI like [type]field because is consistent with drupal's form api.
Comment #24
ericduran CreditAttribution: ericduran commentedSwitching it back to active, because of the naming issues with other modules.
Comment #25
Dave ReidI also agree to be consistent with the core form API elements since we want to get these into core for D8. Changed all the field types to [type]field.
http://drupal.org/cvs?commit=404760
Comment #26
seutje CreditAttribution: seutje commentedbeen doing some work parallel to this, mainly attribute related (like datalist and stuff) and server-side validation related, a field taking a pattern attribute should also check against this pattern on the server-side, but one of the problems is that the markup takes regex in JS format, whereas the server needs it in PHP format...
Comment #27
Dave ReidOpen new issue plz.
Comment #28
seutje CreditAttribution: seutje commentedsry, didn't mean to cross-post :x
Comment #30
bleen CreditAttribution: bleen commentedJust a quick update ... FF4 Beta now supports "search", "tel", "url" & "email"