In commerce_registration.checkout_pane.inc it is checked whether the mail address is required - only then the email is validated.

As for registration-7.x-1.x-dev the email address cannot me set to required.

Thus this line (181ish) will alway return false.

$mail_is_required = $form['registration_information'][$prodkey][$prodkey . '-reg-' . $i]['anon_mail']['#required'];

For my setup I changed this to:

$mail_is_required = TRUE;
CommentFileSizeAuthor
#7 email-required-1892494-7.patch1.88 KBleducdubleuet

Comments

mallezie’s picture

I think it's better to use a form alter to set the form element to required, than you don't have to 'hack' commerce_registration.

nhck’s picture

Priority: Minor » Normal

It would be better to fix the bug.

$form['registration_information'][$prodkey][$prodkey . '-reg-' . $i]['anon_mail']['#required']; - can by definition, never be true thus this whole line and mechanism is pointless. It also adds a wrong decision to commcerce_registration b/c the email adresses are never validated.

jpontani’s picture

Status: Active » Fixed

$form['registration_information'][$prodkey][$prodkey . '-reg-' . $i]['anon_mail']['#required'] can be set to true with a hook_form_registration_form alter implementation.

However, I changed the logic to better incorporate valid email address checking if the user enters anything into that field.

http://drupalcode.org/project/commerce_registration.git/commitdiff/b39b30d

Status: Fixed » Closed (fixed)

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

Sammii’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

@jpontani Can you please clarify specifically how to set the email field on the Registration form to be required?

This thread in Entity Registrations Issue Queue implies that the field should be required but just does not display as such. However, I am able to submit the Registration form with a blank Email field and I encounter no errors. I do not see any settings in the admin that allow me to make this a required field, but neither could I remove it if I wanted! Tried both the beta and the dev versions of Commerce Registration.

You mentioned:

$form['registration_information'][$prodkey][$prodkey . '-reg-' . $i]['anon_mail']['#required'] can be set to true with a hook_form_registration_form alter implementation.

Can you please detail exactly how to code this? I updated to dev version and created a module where I try to call hook_commerce_registration_information_checkout_form_alter() (based on information from https://drupal.org/node/1927376) but it doesn't appear to be firing...

alan d.’s picture

@jpontani
If you do that, then that hidden field with other registration types will flag a validation error??

The default behaviour is required, so $mail_is_required = TRUE; appears to be correct in relation to the parent module (albeit not the cleanest way to implement this).

leducdubleuet’s picture

Status: Active » Needs review
StatusFileSize
new1.88 KB

Since the parent module is requiring the mail field by default, I believe that commerce registration should do the same. It makes no sense to have to implement a hook or to hack $mail_is_required = TRUE; in order to achieve what should be default. Also, I have experienced entity malformed exceptions caused by empty email field with current Commerce Registration 7.x-2.1 and Entity Registration 7.x-1.6. Turns out they were caused by multiple registrations on the same order.

So I propose the attached patch to make the mail field required in the checkout form by default to be inline with entity registration and prevent errors since it is not ready to have that field optional.

DevJoshLopez’s picture

Tested #7 and it works. It does not show a required asterisk though. Thank you!

alejcerro’s picture

I've also tested #7 and it works for me. This should be incorporated into the module since the default functionality doesn't actually work, i.e. email field for "other" users is not actually required.

john.oltman’s picture

Status: Needs review » Closed (outdated)