| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
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
*
* @param string $groupElementType
*
- * @static
*/
- static function buildQuickForm(
+ public static function buildQuickForm(
&$form,
$contactId = 0,
$type = self::ALL,
}
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);
$form->assign('tagGroup', $form->_tagGroup);
}
+ /**
+ * Climb tree.
+ *
+ * @param $form
+ * @param $tree
+ * @param $elements
+ *
+ * @return mixed
+ */
public static function climbtree($form, $tree, &$elements) {
foreach ($tree as $tagID => $varValue) {
$tagAttribute = array(
}
/**
- * Set defaults for relevant form elements
+ * Set defaults for relevant form elements.
*
* @param int $id
* The contact id.
* @param string $groupElementType
*
* @return void
- * @static
*/
public static function setDefaults($id, &$defaults, $type = self::ALL, $fieldName = NULL, $groupElementType = 'checkbox') {
$type = (int ) $type;
}
}
}
+
}