Event online registration validation error under narrow conditions related to multiple participant, $0 fee, and contact reference field permissions: "Your payment information looks incomplete. Please go back to the main registration page, to complete ..."
Under a very specific set of circumstances, users are unable to complete online event registration because of the validation error:
Please correct the following errors in the form fields below:
Your payment information looks incomplete. Please go back to the main registration page, to complete payment information.
Setup:
To reproduce this you will need:
-
An event with the following characteristics:
- Configured for online registration, with multiple participants, and with pricing that allows for a $0 amount on the first participant.
- Includes a profile which contains a required contact reference field.
-
A user role with permissions to register for this event, but without the "access contact reference fields" permission.
Repro steps:
Once you have that set up you can reproduce as follows:
- As a user with the given role, open the online registration form for this event.
- Indicate that you are registering for two participants.
- On the registration form for either of these two participants, you will notice that the contact reference field is not displayed, as expected in light of the user's permissions.
- For the first participant, ensure that you select price options totaling $0.
- Proceed to register the second participant, and for this participant ensure that you select a fee amount of greater than $0.
- Submit the registration form for the second participant.
Expected behavior: The event registration is submitted without error (confirmation page or thank-you page is displayed, as appropriate per event configuration)
Actual incorrect behavior: Submission of the final participant form results in the above-stated validation error.
Strict requirements for repro:
It's worth noting that you can avoid this error by making any one or more of the following changes to the above steps or set up:
- as admin:
- Change permission so that this user can access contact reference fields.
- Do not make the contact reference field required in the profile.
- as user:
- For the first participant, select fees totaling greater than $0.
- For the second participant, select fees totalling $0.
How the code allows this wackiness to happen:
- This line in CRM_Core_Form::validateMandatoryFields adds a validation error to the form if the required contact reference field has no value, without regard for whether the user had permissioned access to the field.
-
This line in CRM_Event_Form_Registration_AdditionalParticipant::validatePaymentValues avoids calling
CRM_Core_Form::validateMandatoryFields()
if the first participant had a fee of more than $0.
(Joinery internal ticket reference: F#1041)