-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#785 Differentiate smart group from regular group using icon in select2 field #17927
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -870,8 +870,10 @@ public function postProcess() { | |
} | ||
|
||
$group = $params['group'] ?? NULL; | ||
if (!empty($group) && is_array($group)) { | ||
unset($params['group']); | ||
$params['group'] = ($params['group'] == '') ? [] : $params['group']; | ||
if (!empty($group)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRM_Utils_Array::value is being mercilessly removed everywhere in civi. So it should be the original line |
||
$group = is_array($group) ? $group : explode(',', $group); | ||
$params['group'] = []; | ||
foreach ($group as $key => $value) { | ||
$params['group'][$value] = 1; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,17 +102,17 @@ public static function buildQuickForm( | |
} | ||
|
||
if ($groupElementType == 'select') { | ||
$groupsOptions[$id] = $group['title']; | ||
$groupsOptions[$id] = $group; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just have one more thing: line 109 just below also needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @demeritcowboy actually its fine, because its affecting only the group select widget, which now takes the array of information instead of just group title, as now we are supporting select2. The reason why the entire $group array is set, Whereas for advanced checkbox widget, it still needs only the group title as per old behaivour. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try adding group to a profile though and then using the profile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops my bad ... updated now |
||
} | ||
else { | ||
$form->_tagGroup[$fName][$id]['description'] = $group['description']; | ||
$elements[] = &$form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes); | ||
$elements[] = &$form->addElement('advcheckbox', $id, NULL, $group['text'], $attributes); | ||
} | ||
} | ||
|
||
if ($groupElementType == 'select' && !empty($groupsOptions)) { | ||
$form->add('select', $fName, $groupName, $groupsOptions, FALSE, | ||
['id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2 twenty'] | ||
$form->add('select2', $fName, $groupName, $groupsOptions, FALSE, | ||
['placeholder' => '- select -', 'multiple' => TRUE, 'class' => 'twenty'] | ||
); | ||
$form->assign('groupCount', count($groupsOptions)); | ||
} | ||
|
@@ -166,11 +166,11 @@ public static function setDefaults($id, &$defaults, $type = self::ALL, $fieldNam | |
|
||
$contactGroup = CRM_Contact_BAO_GroupContact::getContactGroup($id, 'Added', NULL, FALSE, TRUE); | ||
if ($contactGroup) { | ||
foreach ($contactGroup as $group) { | ||
if ($groupElementType == 'select') { | ||
$defaults[$fName][] = $group['group_id']; | ||
} | ||
else { | ||
if ($groupElementType == 'select') { | ||
$defaults[$fName] = implode(',', CRM_Utils_Array::collect('group_id', $contactGroup)); | ||
} | ||
else { | ||
foreach ($contactGroup as $group) { | ||
$defaults[$fName . '[' . $group['group_id'] . ']'] = 1; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array() syntax seems to have come back. While I personally prefer array() the civi standard is now square brackets.