Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure custom field checkboxes are populated in profiles #17562

Conversation

jmcclelland
Copy link
Contributor

Overview

Ensure that custom fields that use the checkbox html type are populated when viewing an existing record, i.e. when using the "Update multiple contacts" search action.

Replicate

  1. Create a custom field group that extends the individual
  2. Create a field (Alphanumeric / Checkbox) with two options.
  3. Create a profile called "Update contact" and add the field you just created.
  4. Find a contact and populate the field you just created with one or more values.
  5. Perform a search for all contacts with the field populated to the value you used
  6. Select the one record
  7. Choose "Update multiple contacts"
  8. Choose the profile "Update contact" that you just created
  9. View whether or not the field you created is displayed with populated data

Before

When you run "Update Multiple Contacts" on a profile with a custom checkbox field, the existing values are not shown. All contacts show no checkboxes checked even if their contact record shows that they have checkboxes checked.

After

Now, checkboxes are properly checked.

Technical Details

The checkbox field is an outlier when it comes to handling default data. Select, Multi-select, radio and other fields with one or more values will work fine with one entry in the $defaults array that is set to an array of values to populate.

But the checkbox needs each individual checkbox that should be checked to be an entry in the $defaults array.

Comments

Maybe it would be better to fix the form layer so that checkboxes could accept default values in the same format as all the other fields??

Also @colemanw - this code was very recently touched by you - so I hope I'm not clobbering some other functionality that you fixed in d4502c2.

@civibot
Copy link

civibot bot commented Jun 9, 2020

(Standard links)

@civibot civibot bot added the master label Jun 9, 2020
@mlutfy
Copy link
Member

mlutfy commented Jun 22, 2020

jenkins, test this please

@colemanw
Copy link
Member

colemanw commented Jul 6, 2020

retest this please

1 similar comment
@colemanw
Copy link
Member

retest this please

@eileenmcnaughton
Copy link
Contributor

@jmcclelland the test fail does relate

api_v3_ProfileTest::testProfileGetWithAddressCustomData
Failure in api call for Profile get: Undefined index: address_custom_1-Primary
#0 /home/jenkins/bknix-dfl/build/core-17562-555eb/web/sites/all/modules/civicrm/CRM/Core/BAO/UFGroup.php(2422): PHPUnit\Util\ErrorHandler::handleError(8, 'Undefined index...', '/home/jenkins/b...', 2422, Array)
#1 /home/jenkins/bknix-dfl/build/core-17562-555eb/web/sites/all/modules/civicrm/api/v3/Profile.php(102): CRM_Core_BAO_UFGroup::setProfileDefaults(5, Array, Array, true)
#2 /home/jenkins/bknix-dfl/build/core-17562-555eb/web/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_profile_get(Array)

@eileenmcnaughton
Copy link
Contributor

I put up a cut down version of this here #17977 - which should survive the test fail

@eileenmcnaughton
Copy link
Contributor

closing per #17977

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants