class CRM_Contact_Form_Edit_TagsAndGroups {
/**
- * Constant to determine which forms we are generating
+ * Constant to determine which forms we are generating.
*
* Used by both profile and edit contact
*/
const GROUP = 1, TAG = 2, ALL = 3;
/**
- * build form elements
+ * build form elements.
* params object $form object of the form
*
* @param CRM_Core_Form $form
}
if ($type & self::TAG) {
- // CODE FROM CRM/Tag/Form/Tag.php //
- CRM_Core_Resources::singleton()
- ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
- ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
-
$fName = 'tag';
if ($fieldName) {
$fName = $fieldName;
// get the list of all the categories
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree('civicrm_contact', TRUE);
+ // let's not load jstree if there are not children. This also fixes blank
+ // display at the beginning of checkboxes
+ $form->assign('loadjsTree', FALSE);
+ if (!empty(CRM_Utils_Array::retrieveValueRecursive($tree, 'children'))) {
+ // CODE FROM CRM/Tag/Form/Tag.php //
+ CRM_Core_Resources::singleton()
+ ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
+ ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
+ $form->assign('loadjsTree', TRUE);
+ }
$elements = array();
self::climbtree($form, $tree, $elements);
}
/**
- * Set defaults for relevant form elements
+ * Set defaults for relevant form elements.
*
* @param int $id
* The contact id.