Commit 21bef7d 1 parent 2419e44 commit 21bef7d Copy full SHA for 21bef7d
File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -179,8 +179,11 @@ public function action_delete_index()
179
179
{
180
180
$ form_id = $ this ->request ->param ('id ' , 0 );
181
181
$ form = ORM ::factory ('Form ' , $ form_id );
182
+ $ this ->_response_payload = array ();
182
183
if ( $ form ->loaded () )
183
184
{
185
+ // Return the form we just deleted (provides some confirmation)
186
+ $ this ->_response_payload = $ this ->form ($ form );
184
187
$ form ->delete ();
185
188
}
186
189
}
Original file line number Diff line number Diff line change @@ -75,4 +75,27 @@ public function rules()
75
75
// Insert/Update Timestamps
76
76
protected $ _created_column = array ('column ' => 'created ' , 'format ' => TRUE );
77
77
protected $ _updated_column = array ('column ' => 'updated ' , 'format ' => 'Y-m-d H:i:s ' );
78
+
79
+ /**
80
+ * Deletes a single record while ignoring relationships.
81
+ * Extend ORM::delete() to cascade delete assoc. objects
82
+ *
83
+ * @chainable
84
+ * @return ORM
85
+ */
86
+ public function delete ()
87
+ {
88
+ // Delete associated objects
89
+ if ($ this ->form_attributes ->loaded ())
90
+ {
91
+ $ this ->form_attributes ->delete ();
92
+ }
93
+
94
+ if ($ this ->form_groups ->loaded ())
95
+ {
96
+ $ this ->form_groups ->delete ();
97
+ }
98
+
99
+ parent ::delete ();
100
+ }
78
101
}
You can’t perform that action at this time.
0 commit comments