From 379d6cd71a4ecd622b12efab9a12dfbf3498548e Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 8 Apr 2019 09:50:56 +1200 Subject: [PATCH] Convert Recurring forms to entity forms --- CRM/Contribute/Form/ContributionRecur.php | 18 ++++++++++++++++++ CRM/Core/Form/EntityFormTrait.php | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/CRM/Contribute/Form/ContributionRecur.php b/CRM/Contribute/Form/ContributionRecur.php index 6d3416ff78..24ad758222 100644 --- a/CRM/Contribute/Form/ContributionRecur.php +++ b/CRM/Contribute/Form/ContributionRecur.php @@ -36,6 +36,8 @@ */ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form { + use CRM_Core_Form_EntityFormTrait; + /** * @var int Contribution ID */ @@ -76,6 +78,21 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form { */ public $_paymentProcessor = []; + /** + * Fields for the entity to be assigned to the template. + * + * Fields may have keys + * - name (required to show in tpl from the array) + * - description (optional, will appear below the field) + * - not-auto-addable - this class will not attempt to add the field using addField. + * (this will be automatically set if the field does not have html in it's metadata + * or is not a core field on the form's entity). + * - help (option) add help to the field - e.g ['id' => 'id-source', 'file' => 'CRM/Contact/Form/Contact']] + * - template - use a field specific template to render this field + * @var array + */ + protected $entityFields = []; + /** * Explicitly declare the entity api name. */ @@ -94,6 +111,7 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form { * Set variables up before form is built. */ public function preProcess() { + $this->setAction(CRM_Core_Action::UPDATE); $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE); $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); $this->contributionRecurID = $this->_crid; diff --git a/CRM/Core/Form/EntityFormTrait.php b/CRM/Core/Form/EntityFormTrait.php index 38f2548208..00a5c5b6e0 100644 --- a/CRM/Core/Form/EntityFormTrait.php +++ b/CRM/Core/Form/EntityFormTrait.php @@ -64,6 +64,20 @@ trait CRM_Core_Form_EntityFormTrait { return $this->deleteMessage; } + /** + * Set the delete message. + * + * We do this from the constructor in order to do a translation. + */ + public function setDeleteMessage() { + } + + /** + * Set entity fields to be assigned to the form. + */ + protected function setEntityFields() { + } + /** * Get the entity id being edited. * -- 2.25.1