The excellent Elements makes "email" type fields available. And if you have HTML5 Tools enabled, the email field on the register form will be converted to an "email" type field.

However, since Email Registration changes the username on login form to expect email addresses, I propose that if the Elements module is enabled, we change the input type to "email". We can do that by default, or give the user an option to enable/disable it.

Patch coming shortly.

Comments

greggles’s picture

Seems like a fine idea to me. There's a bit of a chicken-and-egg situation whether those tools should modify this one or this one should leverage that one, but I'm happy to add support to email_registration, especially since you've got a patch coming.

joelstein’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new2.59 KB

Thanks! I don't think this patch would work well in HTML5 Tools, since Email Registration has its own logic about whether or not the username field is an email field or an email AND username field. Thus, I think the Elements support should come from this module.

The attached patch adds a checkbox to the Account settings page, labeled, "Use HTML5 email field", with a description, "Modify the user login textfield to an HTML5 type='email' field." It only appears if "Allow users login with e-mail or username" is unchecked. It's hidden altogether from the form if Elements is not installed.

With this patch, if Elements is installed, and "Allow users login with e-mail or username" is unchecked, and "Use HTML5 email field" is checked, then the login form (and login block form) textfield will be replaced with type="email".

joelstein’s picture

StatusFileSize
new3.08 KB

Here's a patch which also alters the Forgot Password form.

The last submitted patch, 2: email_registration-html5-2330007-2.patch, failed testing.

joelstein’s picture

StatusFileSize
new3.67 KB

Here's an updated patch which also changes the email field on the user registration form, deletes the variable on uninstall, and adds a simple function which we can use several times to perform the same logic.

Would love to see this committed. HTML5 is here to stay, and this makes a very nice usability improvement for mobile devices.

joelstein’s picture

StatusFileSize
new3.83 KB

Oops, I forgot the #states bit on the accounts settings form.

andypost’s picture

Status: Needs review » Needs work

For d8 we are using email element all over #2825909: Password Reset Email Field Type

+++ b/email_registration.module
@@ -183,9 +199,9 @@ function email_registration_form_user_admin_settings_alter(&$form, &$form_state)
+  variable_set('email_registration_email_field', $form_state['values']['email_registration_email_field']);

this also needs implement hook_modules_disable() to unset this var

greggles’s picture

Title: Use email-type field is Elements module is enabled » Use email-type field if Elements module is enabled (D7 only)

Fixing title and noting that we don't need to forward port to d8.

joelstein’s picture

Status: Needs work » Needs review

The 'email_registration_email_field' variable is deleted in hook_uninstall() in the patch from #6, so I think we're good there.

andypost’s picture

Status: Needs review » Needs work

I mean email registration should have this hook to unset this variable when elements module disabled/removed

joelstein’s picture

Status: Needs work » Needs review

Ah, I see. I don't believe that it necessary. The variable only applies to the namespace of "email_registration", and if the Elements module is ever re-enabled, it would make sense that the setting would stay the same.

It suffices to simply remove the variable when the Email Registration module is uninstalled.

andypost’s picture

Assigned: Unassigned » greggles
Status: Needs review » Reviewed & tested by the community

Sorry for derail, I misread the patch

+++ b/email_registration.module
@@ -228,3 +244,13 @@ function email_registration_user_login_validate($form, &$form_state) {
+function email_registration_email_field(&$element) {
+  if (module_exists('elements') && variable_get('email_registration_email_field', FALSE)) {

Somehow I missed this wrapper

greggles’s picture

Looks good to me. Just fixing up credit info.

  • greggles committed 50a0ff4 on 7.x-1.x authored by joelstein
    Issue #2330007 by joelstein, greggles, andypost: Use email-type field if...
greggles’s picture

Status: Reviewed & tested by the community » Fixed

Great, this is now committed. Thanks!

joelstein’s picture

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.