From 98c54bff0cd49e0f47c223666420b991341b9e67 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Sun, 28 Feb 2016 23:43:23 -0500 Subject: [PATCH] CRM-17614 show survey custom fields in petition and survey UI ---------------------------------------- * CRM-17614: Survey Custom Fields in Petition UI https://issues.civicrm.org/jira/browse/CRM-17614 --- CRM/Campaign/Form/Petition.php | 11 ++++++++++- CRM/Campaign/Form/Survey.php | 9 +++++++++ templates/CRM/Campaign/Form/Petition.tpl | 12 ++++++++++++ templates/CRM/Campaign/Form/Survey/Main.tpl | 12 ++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CRM/Campaign/Form/Petition.php b/CRM/Campaign/Form/Petition.php index 6931a7917f..44fbbe2f31 100644 --- a/CRM/Campaign/Form/Petition.php +++ b/CRM/Campaign/Form/Petition.php @@ -66,8 +66,11 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form { // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { - CRM_Custom_Form_CustomData::preProcess($this); + $this->set('type', 'Event'); + $this->set('entityId', $this->_surveyId); + CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId); CRM_Custom_Form_CustomData::buildQuickForm($this); + CRM_Custom_Form_CustomData::setDefaultValues($this); } $session = CRM_Core_Session::singleton(); @@ -318,6 +321,12 @@ WHERE $whereClause $params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0); $params['is_default'] = CRM_Utils_Array::value('is_default', $params, 0); + $customFields = CRM_Core_BAO_CustomField::getFields('Survey'); + $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, + $this->_surveyId, + 'Survey' + ); + $surveyId = CRM_Campaign_BAO_Survey::create($params); // also update the ProfileModule tables diff --git a/CRM/Campaign/Form/Survey.php b/CRM/Campaign/Form/Survey.php index 7ebc9887f0..2f7f2894e4 100644 --- a/CRM/Campaign/Form/Survey.php +++ b/CRM/Campaign/Form/Survey.php @@ -78,6 +78,15 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form { $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); + // when custom data is included in this page + if (!empty($_POST['hidden_custom'])) { + $this->set('type', 'Event'); + $this->set('entityId', $this->_surveyId); + CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId); + CRM_Custom_Form_CustomData::buildQuickForm($this); + CRM_Custom_Form_CustomData::setDefaultValues($this); + } + // CRM-11480, CRM-11682 // Preload libraries required by the "Questions" tab CRM_UF_Page_ProfileEditor::registerProfileScripts(); diff --git a/templates/CRM/Campaign/Form/Petition.tpl b/templates/CRM/Campaign/Form/Petition.tpl index 7850150150..98f4860510 100644 --- a/templates/CRM/Campaign/Form/Petition.tpl +++ b/templates/CRM/Campaign/Form/Petition.tpl @@ -117,6 +117,18 @@ +
+ {*include custom data js file*} + {include file="CRM/common/customData.tpl"} + {literal} + + {/literal} {/if}
{include file="CRM/common/formButtons.tpl" location="bottom"}
diff --git a/templates/CRM/Campaign/Form/Survey/Main.tpl b/templates/CRM/Campaign/Form/Survey/Main.tpl index 0856d1858d..ed581701c6 100644 --- a/templates/CRM/Campaign/Form/Survey/Main.tpl +++ b/templates/CRM/Campaign/Form/Survey/Main.tpl @@ -83,6 +83,18 @@ +
+ {*include custom data js file*} + {include file="CRM/common/customData.tpl"} + {literal} + + {/literal}
{include file="CRM/common/formButtons.tpl" location="bottom"}
-- 2.25.1