Existing Contact with locked fields: Searching for number and then pressing Create New and filling form fails to create contact

Created on 13 September 2024, 3 months ago

1.0 Problem/Motivation
If you have an Existing Contact field associated with locked fields, searching for a contact by a number and then pressing Create New will not create the contact.

2.0 Detailed steps to reproduce (embed screenshots)

  • Import the .yml webform attached
  • View the form
  • Search for a number in the Existing Contact field (e.g. "3")
  • Press "+ Create New +"
  • Enter a name into the name fields
  • Submit the form
  • Observe that the contact has not been created

3.0 Proposed resolution
The problem is essentially the same as this issue relating to the D7 version of webform_civicrm, and it's caused by an equivalent bit of code:

https://www.drupal.org/project/webform_civicrm/issues/3358082 🐛 Existing Contact - Create New failure after numeric search with locked fields Active

The issue is caused by this line:

https://github.com/colemanw/webform_civicrm/blob/6.x/src/WebformCivicrmP...

It can be solved by changing it to this:

      if (!$existing_contact_val[0] || ((is_numeric($existing_contact_val[0]) && ((int)$existing_contact_val[0] > 0)))) {
🐛 Bug report
Status

Active

Version

6.2

Component

CiviCRM Data Handling

Created by

🇦🇺Australia jude.hungerford

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024