2015-08-11 08:21:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies that this ends a group of fields
|
|
|
|
*/
|
|
|
|
class EditableFieldGroup extends EditableFormField {
|
|
|
|
|
2015-08-12 07:18:43 +02:00
|
|
|
private static $has_one = array(
|
|
|
|
'End' => 'EditableFieldGroupEnd'
|
|
|
|
);
|
|
|
|
|
2015-08-11 08:21:43 +02:00
|
|
|
/**
|
|
|
|
* Disable selection of group class
|
|
|
|
*
|
|
|
|
* @config
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
private static $hidden = true;
|
2015-08-12 06:08:32 +02:00
|
|
|
|
|
|
|
public function getCMSFields() {
|
|
|
|
$fields = parent::getCMSFields();
|
|
|
|
$fields->removeByName(array('MergeField', 'Default', 'Validation', 'DisplayRules'));
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
2015-08-12 07:18:43 +02:00
|
|
|
public function getCMSTitle() {
|
|
|
|
return _t(
|
|
|
|
'EditableFieldGroupEnd.FIELD_GROUP_START',
|
|
|
|
'Start of {group}',
|
|
|
|
array(
|
|
|
|
'group' => $this->Title ?: 'group'
|
|
|
|
)
|
2015-08-12 06:08:32 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-08-12 07:18:43 +02:00
|
|
|
public function getInlineClassnameField($column, $fieldClasses) {
|
|
|
|
return new LabelField($column, $this->CMSTitle);
|
|
|
|
}
|
|
|
|
|
2015-08-12 06:08:32 +02:00
|
|
|
public function showInReports() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFormField() {
|
|
|
|
$field = UserFormsGroupField::create()
|
|
|
|
->setTitle($this->EscapedTitle ?: false);
|
|
|
|
$this->doUpdateFormField($field);
|
|
|
|
return $field;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function updateFormField($field) {
|
|
|
|
// set the right title on this field
|
|
|
|
if($this->RightTitle) {
|
|
|
|
// Since this field expects raw html, safely escape the user data prior
|
|
|
|
$field->setRightTitle(Convert::raw2xml($this->RightTitle));
|
|
|
|
}
|
|
|
|
|
|
|
|
// if this field has an extra class
|
|
|
|
if($field->ExtraClass) {
|
|
|
|
$field->addExtraClass($field->ExtraClass);
|
|
|
|
}
|
|
|
|
}
|
2015-08-12 07:18:43 +02:00
|
|
|
|
|
|
|
protected function onBeforeDelete() {
|
|
|
|
parent::onBeforeDelete();
|
|
|
|
|
|
|
|
// Ensures EndID is lazy-loaded for onAfterDelete
|
|
|
|
$this->EndID;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function onAfterDelete() {
|
|
|
|
parent::onAfterDelete();
|
|
|
|
|
|
|
|
// Delete end
|
|
|
|
if(($end = $this->End()) && $end->exists()) {
|
|
|
|
$end->delete();
|
|
|
|
}
|
|
|
|
}
|
2015-08-11 08:21:43 +02:00
|
|
|
|
|
|
|
}
|