mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
42 lines
920 B
PHP
42 lines
920 B
PHP
<?php
|
|
/**
|
|
* A modal search dialog which uses search context to search for and add
|
|
* existing records to a grid field.
|
|
*/
|
|
class GridFieldAddExistingSearchButton implements
|
|
GridField_HTMLProvider,
|
|
GridField_URLHandler {
|
|
|
|
protected $fragment;
|
|
|
|
/**
|
|
* @param string $fragment
|
|
*/
|
|
public function __construct($fragment = 'before') {
|
|
$this->fragment = $fragment;
|
|
}
|
|
|
|
public function getHTMLFragments($grid) {
|
|
GridFieldExtensions::include_requirements();
|
|
|
|
$data = new ArrayData(array(
|
|
'Link' => $grid->Link('add-existing-search')
|
|
));
|
|
|
|
return array(
|
|
$this->fragment => $data->renderWith('GridFieldAddExistingSearchButton'),
|
|
);
|
|
}
|
|
|
|
public function getURLHandlers($grid) {
|
|
return array(
|
|
'add-existing-search' => 'handleSearch'
|
|
);
|
|
}
|
|
|
|
public function handleSearch($grid, $request) {
|
|
return new GridFieldAddExistingSearchHandler($grid, $this);
|
|
}
|
|
|
|
}
|