From f7b325337ae21313b4f2ad69aa03e70bb712f804 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 21 Jan 2019 20:13:09 -0500 Subject: [PATCH] Use entityRef for campaigns on Survey & Petition forms --- CRM/Campaign/Form/Petition.php | 7 ++++--- CRM/Campaign/Form/Survey/Main.php | 8 ++++---- templates/CRM/Campaign/Form/Survey/Main.tpl | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CRM/Campaign/Form/Petition.php b/CRM/Campaign/Form/Petition.php index b94e55f14e..7257478b1e 100644 --- a/CRM/Campaign/Form/Petition.php +++ b/CRM/Campaign/Form/Petition.php @@ -190,9 +190,10 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form { // script / instructions / description of petition purpose $this->add('wysiwyg', 'instructions', ts('Introduction'), $attributes['instructions']); - // Campaign id - $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values)); - $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); + $this->addEntityRef('campaign_id', ts('Campaign'), [ + 'entity' => 'campaign', + 'create' => TRUE, + ]); $customContactProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Individual')); // custom group id diff --git a/CRM/Campaign/Form/Survey/Main.php b/CRM/Campaign/Form/Survey/Main.php index 8bacc32bdd..e0f7fbdda8 100644 --- a/CRM/Campaign/Form/Survey/Main.php +++ b/CRM/Campaign/Form/Survey/Main.php @@ -127,13 +127,13 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey { $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE); - $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType(); // Activity Type id $this->addSelect('activity_type_id', array('option_url' => 'civicrm/admin/campaign/surveyType'), TRUE); - // Campaign id - $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values)); - $this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); + $this->addEntityRef('campaign_id', ts('Campaign'), [ + 'entity' => 'campaign', + 'create' => TRUE, + ]); // script / instructions $this->add('wysiwyg', 'instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40)); diff --git a/templates/CRM/Campaign/Form/Survey/Main.tpl b/templates/CRM/Campaign/Form/Survey/Main.tpl index fc73733dbe..f78c3d27c1 100644 --- a/templates/CRM/Campaign/Form/Survey/Main.tpl +++ b/templates/CRM/Campaign/Form/Survey/Main.tpl @@ -39,7 +39,7 @@ {$form.campaign_id.label} - {$form.campaign_id.html}   {ts}new campaign{/ts} + {$form.campaign_id.html}
{ts}Select the campaign for which survey is created.{/ts}
-- 2.25.1