2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Contents of an UserDefinedForm submission
|
2009-12-07 03:04:20 +01:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
2009-12-07 03:04:20 +01:00
|
|
|
|
2008-09-29 05:18:23 +02:00
|
|
|
class SubmittedForm extends DataObject {
|
2010-09-03 07:06:13 +02:00
|
|
|
|
2012-05-09 05:17:06 +02:00
|
|
|
public static $has_one = array(
|
2008-09-29 05:18:23 +02:00
|
|
|
"SubmittedBy" => "Member",
|
|
|
|
"Parent" => "UserDefinedForm",
|
|
|
|
);
|
|
|
|
|
2012-05-09 05:17:06 +02:00
|
|
|
public static $has_many = array(
|
2010-09-08 12:35:43 +02:00
|
|
|
"Values" => "SubmittedFormField"
|
2008-09-29 05:18:23 +02:00
|
|
|
);
|
2012-05-09 05:17:06 +02:00
|
|
|
|
2009-04-15 00:59:46 +02:00
|
|
|
/**
|
2009-04-15 06:23:43 +02:00
|
|
|
* Before we delete this form make sure we delete all the
|
|
|
|
* field values so that we don't leave old data round
|
2009-04-15 00:59:46 +02:00
|
|
|
*
|
|
|
|
*/
|
2009-04-15 06:23:43 +02:00
|
|
|
protected function onBeforeDelete() {
|
2010-09-08 12:35:43 +02:00
|
|
|
|
|
|
|
if($this->Values()) {
|
|
|
|
foreach($this->Values() as $value) {
|
2009-04-15 06:23:43 +02:00
|
|
|
$value->delete();
|
|
|
|
}
|
|
|
|
}
|
2010-09-08 12:35:43 +02:00
|
|
|
|
2009-04-15 06:23:43 +02:00
|
|
|
parent::onBeforeDelete();
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
2009-12-07 03:04:20 +01:00
|
|
|
}
|