diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 3bb5fcf7e1d67785ca1ebbb21da531061c841d57..582c40a7833359d87a4ba40408cc39f173579eff 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -1130,6 +1130,15 @@ class DynamicFormEntryAnswer extends VerySimpleModel {
         $v = $this->toString();
         return is_string($v) ? $v : (string) $this->getValue();
     }
+
+    function delete() {
+        if (!parent::delete())
+            return false;
+
+        // Allow the field to cleanup anything else in the database
+        $this->getField()->db_cleanup();
+        return true;
+    }
 }
 
 class SelectionField extends FormField {
diff --git a/include/class.forms.php b/include/class.forms.php
index 01bd11ade51113b13ce482bd25d8e2a7fe128527..0249de4d8cda24f5d7bdd41e72a8496183f6df29 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -397,6 +397,15 @@ class FormField {
         return $this->toString($this->value);
     }
 
+    /**
+     * When data for this field is deleted permanently from some storage
+     * backend (like a database), other associated data may need to be
+     * cleaned as well. This hook allows fields to participate when the data
+     * for a field is cleaned up.
+     */
+    function db_cleanup() {
+    }
+
     /**
      * Returns an HTML friendly value for the data in the field.
      */
@@ -1678,6 +1687,14 @@ class FileUploadField extends FormField {
         }
         return implode(', ', $files);
     }
+
+    function db_cleanup() {
+        // Delete associated attachments from the database, if any
+        $this->getFiles();
+        if (isset($this->attachments)) {
+            $this->attachments->deleteAll();
+        }
+    }
 }
 
 class Widget {
diff --git a/include/class.organization.php b/include/class.organization.php
index 458a1f7eed9a71b2e0cc217153ab2c92845f6286..587d0d5a7654231c4f72fc322a9769be615f74cb 100644
--- a/include/class.organization.php
+++ b/include/class.organization.php
@@ -336,6 +336,15 @@ class Organization extends OrganizationModel {
         return $this->save();
     }
 
+    function delete() {
+        if (!parent::delete())
+            return false;
+
+        foreach ($this->getDynamicData(false) as $entry) {
+            $entry->delete();
+        }
+    }
+
     static function fromVars($vars) {
 
         if (!($org = Organization::lookup(array('name' => $vars['name'])))) {