mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
sanitise classname on addmulticlass handler
This commit is contained in:
parent
f80fc03bbb
commit
0e029a3033
@ -2,16 +2,31 @@
|
|||||||
/**
|
/**
|
||||||
* A custom grid field request handler that allows interacting with form fields when adding records.
|
* A custom grid field request handler that allows interacting with form fields when adding records.
|
||||||
*/
|
*/
|
||||||
class GridFieldAddNewMultiClassHandler extends GridFieldDetailForm_ItemRequest {
|
class GridFieldAddNewMultiClassHandler extends GridFieldDetailForm_ItemRequest
|
||||||
|
{
|
||||||
|
public function Link($action = null)
|
||||||
|
{
|
||||||
|
if ($this->record->ID) {
|
||||||
|
return parent::Link($action);
|
||||||
|
}
|
||||||
|
|
||||||
public function Link($action = null) {
|
return Controller::join_links(
|
||||||
if($this->record->ID) {
|
$this->gridField->Link(),
|
||||||
return parent::Link($action);
|
'add-multi-class',
|
||||||
} else {
|
$this->sanitiseClassName(get_class($this->record))
|
||||||
return Controller::join_links(
|
);
|
||||||
$this->gridField->Link(), 'add-multi-class', get_class($this->record)
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitise a model class' name for inclusion in a link.
|
||||||
|
*
|
||||||
|
* @param mixed $class
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function sanitiseClassName($class)
|
||||||
|
{
|
||||||
|
return str_replace('\\', '-', $class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user