2013-02-02 04:14:59 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A custom grid field request handler that allows interacting with form fields when adding records.
|
|
|
|
*/
|
|
|
|
class GridFieldAddNewMultiClassHandler extends GridFieldDetailForm_ItemRequest {
|
|
|
|
|
|
|
|
public function Link($action = null) {
|
|
|
|
if($this->record->ID) {
|
|
|
|
return parent::Link($action);
|
|
|
|
} else {
|
|
|
|
return Controller::join_links(
|
2017-09-04 06:59:38 +02:00
|
|
|
$this->gridField->Link(), 'add-multi-class', $this->sanitiseClassName(get_class($this->record))
|
2013-02-02 04:14:59 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-04 06:59:38 +02:00
|
|
|
/**
|
|
|
|
* Sanitise a model class' name for inclusion in a link
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function sanitiseClassName($class) {
|
|
|
|
return str_replace('\\', '-', $class);
|
|
|
|
}
|
2013-02-02 04:14:59 +01:00
|
|
|
}
|