Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • A action-provider
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 7
    • Issues 7
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Extensions
  • action-provider
  • Merge requests
  • !90

Custom field using option group returns incorrect values when option values are non-numeric

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged justinfreeman (Agileware) requested to merge justinfreeman/action-provider:CIVICRM-2067 into master Nov 18, 2022
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1

Custom field using option group returns incorrect values when option values are non-numeric.

See org.civicoop.action-provider/Civi/ActionProvider/Action/AbstractGetSingleAction.php

This function returns 0,1,2 for the field when non-numeric values have been saved as multiple options. For example when a option group has both labels and values like: Option X, Option Y, Option Z

  protected function convertCustomFieldWithMultipleValues($value) {
    foreach($value as $k=>$v) {
      if ($k == 0 && $v >= 1) {
        return $value;
      }
    }
    return array_keys($value);
  }

With a small change as shown below, this function then returns the correct values: Option X, Option Y, Option Z for the field.

  protected function convertCustomFieldWithMultipleValues($value) {
        return $value;
  }

I am not sure why this function was required, perhaps it is/was required to workaround a different issue or CiviCRM API bug.

Option group - note that Option X, Option Y, Option Z are both the label and the value. Other options have numeric values

image

Test Activity record with custom field, option values selected

image

Before this patch the Form processor loads the correct values from the Activity record, Field A but the incorrect values for Field B - eek!

image

With this patch the Form processor now loads the correct values from the Activity record, Field A and Field B

image

Agileware Ref: CIVICRM-2067

Edited Nov 18, 2022 by justinfreeman (Agileware)
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: CIVICRM-2067