Fix row ID input not being added for delete form
authorPatrick Figel <pfigel@greenpeace.org>
Fri, 14 Jun 2019 18:26:45 +0000 (20:26 +0200)
committerPatrick Figel <pfigel@greenpeace.org>
Fri, 14 Jun 2019 18:26:45 +0000 (20:26 +0200)
This fixes an issue where the hidden "id" element wasn't added
because the CRM_Core_Action::DELETE handler has an early return.

CRM/Contribute/Form/Contribution.php
CRM/Event/Form/Participant.php

index d7149e5d092e355715cf52a687c393493732241b..79a4db615d218cb5b76314712ecac8ebd9ed9073 100644 (file)
@@ -466,6 +466,10 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
    * Build the form object.
    */
   public function buildQuickForm() {
+    if ($this->_id) {
+      $this->add('hidden', 'id', $this->_id);
+    }
+
     if ($this->_action & CRM_Core_Action::DELETE) {
       $this->addButtons([
         [
@@ -824,7 +828,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     // if contribution is related to membership or participant freeze Financial Type, Amount
     if ($this->_id) {
-      $this->add('hidden', 'id', $this->_id);
       $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
       $isCancelledStatus = ($this->_values['contribution_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Cancelled'));
 
index a1b1c61c17b0f7ab9dc9fc50f89d976fc513723b..fc7b0547f3b8c7636eb6d17b1144bc12412e9731 100644 (file)
@@ -594,6 +594,10 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
    * @throws \CiviCRM_API3_Exception
    */
   public function buildQuickForm() {
+    if ($this->_id) {
+      $this->add('hidden', 'id', $this->_id);
+    }
+
     $participantStatuses = CRM_Event_PseudoConstant::participantStatus();
     $partiallyPaidStatusId = array_search('Partially paid', $participantStatuses);
     $this->assign('partiallyPaidStatusId', $partiallyPaidStatusId);
@@ -689,7 +693,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
 
     if ($this->_id) {
       $this->assign('entityID', $this->_id);
-      $this->add('hidden', 'id', $this->_id);
     }
 
     $this->addSelect('role_id', ['multiple' => TRUE, 'class' => 'huge'], TRUE);