silverstripe-userforms/code/model/submissions/SubmittedForm.php

39 lines
789 B
PHP
Raw Normal View History

<?php
/**
* Contents of an UserDefinedForm submission
*
* @package userforms
*/
class SubmittedForm extends DataObject {
2012-05-09 05:17:06 +02:00
public static $has_one = array(
"SubmittedBy" => "Member",
"Parent" => "UserDefinedForm",
);
2012-05-09 05:17:06 +02:00
public static $has_many = array(
"Values" => "SubmittedFormField"
);
2012-05-09 05:17:06 +02:00
/**
* Before we delete this form make sure we delete all the
* field values so that we don't leave old data round
*
*/
protected function onBeforeDelete() {
if($this->Values()) {
foreach($this->Values() as $value) {
$value->delete();
}
}
parent::onBeforeDelete();
}
// Used in the CMS to join the links properly
public function DeleteLink($controllerLink) {
return Controller::join_links($controllerLink, 'deletesubmission?id=' . $this->ID);
}
}