From: Andrew Hunt Date: Mon, 29 Feb 2016 04:43:23 +0000 (-0500) Subject: CRM-17614 show survey custom fields in petition and survey UI X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=98c54bff0cd49e0f47c223666420b991341b9e67;p=civicrm-core.git 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 --- 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"}