Problem/Motivation

Fields specified in Existing Contact "Fields to lock" are not stored, either in the Webform results or in the CiviCRM Contact record, in the following conditions:

  • New Contact: If "Don't lock fields that are empty" is unchecked.
  • Existing contact: Always.

Proposed resolution

In file webform_civicrm/includes/wf_crm_webform_postprocess.inc.wf_crm_webform_postprocess:

  • isFieldHiddenByExistingContactSettings. Indicates if the field is designated as a "Fields to lock" to be hidden (optionally if not blank) for existing contacts. It also returns true (I presume incorrectly) in the case of a new contact if "Don't lock fields that are empty" is unchecked.
  • fillDataFromSubmission: If for any submitted value the above function returns true, then that value is removed from the Webform submission.

I think there are two issues here:

  1. isFieldHiddenByExistingContactSettings incorrectly returns true on new contacts if "Don't lock fields that are empty" is unchecked, even though no field is actually locked/hidden on the submitted form.
  2. It is not clear why fillDataFromSubmission nulls any data fields that are hidden (or potentially hidden), writing nulls into the webform results. If the hidden/locked fields were populated from the Civi database and are unchangeable in the form, they should be treated as valid submitted fields, written into the Webform results and harmlessly re-written to the contact record.

In any case, all submitted form field values (hidden, locked or otherwise) should be made available in the Webform results and Civi contact record.

Remaining tasks

(reviews needed, tests to be written or run, documentation to be written, etc.)

User interface changes

(New or changed features/functionality in the user interface, modules added or removed, changes to URL paths, changes to user interface text.)

API changes

(API changes/additions that would affect module, install profile, and theme developers, including examples of before/after code if appropriate.)

Data model changes

(Database or configuration data changes that would make stored data on an existing site incompatible with the site's updated codebase, including changes to hook_schema(), configuration schema or keys, or the expected format of stored data, etc.)

Original report by [username]

(Text of the original report, for legacy issues whose initial post was not the issue summary. Use rarely.)

Comments

BobSCA created an issue. See original summary.

hansrossel’s picture

Same problem here.

In fillDataFromSubmission() $val = $this->submissionValue($fid); has empty values for all the fields that have been marked as locked. So the webform does not save any values of locked fields in the Webform results. When setting a locked field as required the validation blocks the form and it cannot be submitted. So the field value of locked fields is empty before validation.

hansrossel’s picture

Version: 7.x-4.15 » 7.x-4.16
hansrossel’s picture

The issue also exists in the current 7.x-4.x-dev

philiphart’s picture

We are affected by this issue as well.

I have a quote from Agileware to fix this.. they have provided bug fixes for CiviCRM/webform for us previously.

I can fund half of their quote. Looking for one or more others to split the remaining $450 to help make this happen.

Contact me here if you can help: http://philhart.com/content/contact-phil

Phil

Agileware’s picture

Agileware is working on a fix for this bug.

Agileware’s picture

Status: Active » Needs review

PR sent through for a solution to this. https://github.com/colemanw/webform_civicrm/pull/50

It includes a Read-only option for 'Fields to lock', which allows the values auto-filled from CiviCRM to be submitted with the form to a) pass required field validation, and b) be saved with the Webform submission.

mpaulson’s picture

Status: Needs review » Closed (outdated)

This issue was filed against a branch (7.x-4.x) that is no longer supported. We're sorry we did not get to work through it, but once you upgrade to 7.x-5.x and if the issue persists, please feel free to re-open.