From 3eb99314865180cc839aa99b70c140990ee0a013 Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 29 Apr 2018 18:17:02 +1200 Subject: [PATCH] Fix Participant batch update to work with multiple value custom fields --- CRM/Activity/Form/Task/Batch.php | 3 +++ CRM/Case/Form/Task/Batch.php | 3 +++ CRM/Contact/Form/Task/Batch.php | 3 +++ CRM/Contribute/Form/Task/Batch.php | 3 +++ CRM/Event/Form/Task/Batch.php | 2 ++ CRM/Member/Form/Task/Batch.php | 5 +++-- tests/phpunit/CRM/Event/Form/Task/BatchTest.php | 5 +++++ 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CRM/Activity/Form/Task/Batch.php b/CRM/Activity/Form/Task/Batch.php index faeef85700..dfb0ae0034 100644 --- a/CRM/Activity/Form/Task/Batch.php +++ b/CRM/Activity/Form/Task/Batch.php @@ -242,6 +242,9 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task { $activityId = civicrm_api3('activity', 'create', $value); // @todo this would be done by the api call above if the parames were passed through. + // @todo extract submit functions & + // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test + // handling of custom data, specifically checkbox fields. if (!empty($value['custom']) && is_array($value['custom']) ) { diff --git a/CRM/Case/Form/Task/Batch.php b/CRM/Case/Form/Task/Batch.php index 9e2f50fcd5..30af5d3888 100644 --- a/CRM/Case/Form/Task/Batch.php +++ b/CRM/Case/Form/Task/Batch.php @@ -98,6 +98,9 @@ class CRM_Case_Form_Task_Batch extends CRM_Core_Form_Task_Batch { ); } //check for custom data + // @todo extract submit functions & + // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test + // handling of custom data, specifically checkbox fields. $value['custom'] = CRM_Core_BAO_CustomField::postProcess($params['field'][$key], $key, 'Case', diff --git a/CRM/Contact/Form/Task/Batch.php b/CRM/Contact/Form/Task/Batch.php index 6bd963c127..c9d4fdd821 100644 --- a/CRM/Contact/Form/Task/Batch.php +++ b/CRM/Contact/Form/Task/Batch.php @@ -217,6 +217,9 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { public function postProcess() { $params = $this->exportValues(); + // @todo extract submit functions & + // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test + // handling of custom data, specifically checkbox fields. $ufGroupId = $this->get('ufGroupId'); $notify = NULL; $inValidSubtypeCnt = 0; diff --git a/CRM/Contribute/Form/Task/Batch.php b/CRM/Contribute/Form/Task/Batch.php index 0036172d98..4563e86e50 100644 --- a/CRM/Contribute/Form/Task/Batch.php +++ b/CRM/Contribute/Form/Task/Batch.php @@ -206,6 +206,9 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { */ public function postProcess() { $params = $this->exportValues(); + // @todo extract submit functions & + // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test + // handling of custom data, specifically checkbox fields. if (isset($params['field'])) { foreach ($params['field'] as $contributionID => $value) { diff --git a/CRM/Event/Form/Task/Batch.php b/CRM/Event/Form/Task/Batch.php index 04927e1d09..7182125242 100644 --- a/CRM/Event/Form/Task/Batch.php +++ b/CRM/Event/Form/Task/Batch.php @@ -478,6 +478,8 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { // Unset the original custom field now that it has been formatting to the 'custom' // array as it may not be in the right format for the api as is (notably for // multiple checkbox values). + // @todo extract submit functions on other Batch update classes & + // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test them. if (substr($fieldName, 0, 7) === 'custom_') { unset($value[$fieldName]); } diff --git a/CRM/Member/Form/Task/Batch.php b/CRM/Member/Form/Task/Batch.php index e1454c8c9a..4e13e6528b 100644 --- a/CRM/Member/Form/Task/Batch.php +++ b/CRM/Member/Form/Task/Batch.php @@ -29,8 +29,6 @@ * * @package CRM * @copyright CiviCRM LLC (c) 2004-2018 - * $Id$ - * */ /** @@ -208,6 +206,9 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { */ public function postProcess() { $params = $this->exportValues(); + // @todo extract submit functions & + // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test + // handling of custom data, specifically checkbox fields. $dates = array( 'join_date', 'membership_start_date', diff --git a/tests/phpunit/CRM/Event/Form/Task/BatchTest.php b/tests/phpunit/CRM/Event/Form/Task/BatchTest.php index 812c26ca18..15f24a48bf 100644 --- a/tests/phpunit/CRM/Event/Form/Task/BatchTest.php +++ b/tests/phpunit/CRM/Event/Form/Task/BatchTest.php @@ -8,6 +8,11 @@ */ class CRM_Event_Form_Task_BatchTest extends CiviUnitTestCase { + /** + * Test the the submit function on the event participant submit function. + * + * @todo extract submit functions on other Batch update classes, use dataprovider to test on all. + */ public function testSubmit() { $group = $this->CustomGroupCreate(['extends' => 'Participant', 'title' => 'Participant']); $field = $this->customFieldCreate(['custom_group_id' => $group['id'], 'html_type' => 'CheckBox', 'option_values' => ['two' => 'A couple', 'three' => 'A few', 'four' => 'Too Many']]); -- 2.25.1