* If used for building tag block.
* @param string $fieldName
* This is used in batch profile(i.e to build multiple blocks).
- *
* @param string $groupElementType
- *
+ * The html type of the element we are adding e.g. checkbox, select
+ * @param bool $public
+ * Is this being used in a public form e.g. Profile.
*/
public static function buildQuickForm(
&$form,
$groupName = 'Group(s)',
$tagName = 'Tag(s)',
$fieldName = NULL,
- $groupElementType = 'checkbox'
+ $groupElementType = 'checkbox',
+ $public = FALSE
) {
if (!isset($form->_tagGroup)) {
$form->_tagGroup = [];
}
if ($groupID || !empty($group)) {
- $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids, NULL, '- ');
+ $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids, NULL, '- ', FALSE, $public);
$attributes['skiplabel'] = TRUE;
$elements = [];
$groupsOptions = [];
- foreach ($groups as $id => $group) {
+ foreach ($groups as $key => $group) {
+ $id = $group['id'];
// make sure that this group has public visibility
if ($visibility &&
$group['visibility'] == 'User and User Admin Only'
}
if ($groupElementType == 'select') {
- $groupsOptions[$id] = $group;
+ $groupsOptions[$key] = $group;
}
else {
$form->_tagGroup[$fName][$id]['description'] = $group['description'];