本文整理汇总了PHP中CRM_Core_Form::get_template_vars方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::get_template_vars方法的具体用法?PHP CRM_Core_Form::get_template_vars怎么用?PHP CRM_Core_Form::get_template_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::get_template_vars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build tag widget if correct parent is passed
*
* @param CRM_Core_Form $form
* Form object.
* @param string $parentNames
* Parent name ( tag name).
* @param string $entityTable
* Entitytable 'eg: civicrm_contact'.
* @param int $entityId
* Entityid 'eg: contact id'.
* @param bool $skipTagCreate
* True if tag need be created using ajax.
* @param bool $skipEntityAction
* True if need to add entry in entry table via ajax.
* @param string $tagsetElementName
* If you need to create tagsetlist with specific name.
*/
public static function buildQuickForm(&$form, $parentNames, $entityTable, $entityId = NULL, $skipTagCreate = FALSE, $skipEntityAction = FALSE, $tagsetElementName = NULL)
{
$tagset = $form->_entityTagValues = array();
$form->assign("isTagset", FALSE);
$mode = NULL;
foreach ($parentNames as &$parentNameItem) {
// get the parent id for tag list input for keyword
$parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $parentNameItem, 'id', 'name');
// check if parent exists
if ($parentId) {
$tagsetItem = $tagsetElementName . 'parentId_' . $parentId;
$tagset[$tagsetItem]['parentID'] = $parentId;
list(, $mode) = explode('_', $entityTable);
if (!$tagsetElementName) {
$tagsetElementName = $mode . "_taglist";
}
$tagset[$tagsetItem]['tagsetElementName'] = $tagsetElementName;
$form->addEntityRef("{$tagsetElementName}[{$parentId}]", $parentNameItem, array('entity' => 'tag', 'multiple' => TRUE, 'create' => !$skipTagCreate, 'api' => array('params' => array('parent_id' => $parentId)), 'data-entity_table' => $entityTable, 'data-entity_id' => $entityId, 'class' => "crm-{$mode}-tagset"));
if ($entityId) {
$tagset[$tagsetItem]['entityId'] = $entityId;
$entityTags = CRM_Core_BAO_EntityTag::getChildEntityTags($parentId, $entityId, $entityTable);
if ($entityTags) {
$form->setDefaults(array("{$tagsetElementName}[{$parentId}]" => implode(',', array_keys($entityTags))));
}
} else {
$skipEntityAction = TRUE;
}
$tagset[$tagsetItem]['skipEntityAction'] = $skipEntityAction;
}
}
if (!empty($tagset)) {
// assign current tagsets which is used in postProcess
$form->_tagsetInfo = $tagset;
$form->assign("tagsetType", $mode);
// Merge this tagset info with possibly existing info in the template
$tagsetInfo = (array) $form->get_template_vars("tagsetInfo");
if (empty($tagsetInfo[$mode])) {
$tagsetInfo[$mode] = array();
}
$tagsetInfo[$mode] = array_merge($tagsetInfo[$mode], $tagset);
$form->assign("tagsetInfo", $tagsetInfo);
$form->assign("isTagset", TRUE);
}
}