Skip to content

Commit

Permalink
Fix Participant batch update to work with multiple value custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Apr 29, 2018
1 parent d94ee64 commit 3eb9931
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CRM/Activity/Form/Task/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ public function postProcess() {
$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'])
) {
Expand Down
3 changes: 3 additions & 0 deletions CRM/Case/Form/Task/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public function postProcess() {
);
}
//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',
Expand Down
3 changes: 3 additions & 0 deletions CRM/Contact/Form/Task/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ public static function formRule($fields) {
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;
Expand Down
3 changes: 3 additions & 0 deletions CRM/Contribute/Form/Task/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public function setDefaultValues() {
*/
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) {

Expand Down
2 changes: 2 additions & 0 deletions CRM/Event/Form/Task/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ public function submit($params) {
// 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]);
}
Expand Down
5 changes: 3 additions & 2 deletions CRM/Member/Form/Task/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2018
* $Id$
*
*/

/**
Expand Down Expand Up @@ -208,6 +206,9 @@ public function setDefaultValues() {
*/
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',
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/CRM/Event/Form/Task/BatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']]);
Expand Down

0 comments on commit 3eb9931

Please sign in to comment.