dev/core#715 - Fix delete action on RelationshipType form
[civicrm-core.git] / CRM / Core / Form / EntityFormTrait.php
index a1133f5dfea706c7e40a4ce2c13eed11b0763424..6693f88dfafe341bf3554f854c0edf7c5d6240d8 100644 (file)
@@ -168,7 +168,7 @@ trait CRM_Core_Form_EntityFormTrait {
     }
     foreach ($this->entityFields as $fieldSpec) {
       $value = CRM_Utils_Request::retrieveValue($fieldSpec['name'], $this->getValidationTypeForField($fieldSpec['name']));
-      if ($value !== FALSE) {
+      if ($value !== FALSE && $value !== NULL) {
         $defaults[$fieldSpec['name']] = $value;
       }
     }
@@ -250,6 +250,10 @@ trait CRM_Core_Form_EntityFormTrait {
         // We can't load this field using metadata
         continue;
       }
+      if ($field != 'id' && $this->isDeleteContext()) {
+        // Delete forms don't generally present any fields to edit
+        continue;
+      }
       // Resolve action.
       if (empty($props['action'])) {
         $props['action'] = $this->getApiAction();