mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: add custom search function, so the search catches also the Titles (search uses DataObject::get, which bypasses the getMenuTitle function) (from r97755)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102530 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
29ea7e0b98
commit
d294c0f755
@ -207,6 +207,15 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
$this->controller = $controller;
|
$this->controller = $controller;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches the SiteTree for display in the dropdown
|
||||||
|
*
|
||||||
|
* @return callback
|
||||||
|
*/
|
||||||
|
function siteTreeSearchCallback($sourceObject, $labelField, $search) {
|
||||||
|
return DataObject::get($sourceObject, "\"MenuTitle\" LIKE '%$search%' OR \"Title\" LIKE '%$search%'");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link Form} instance allowing a user to
|
* Return a {@link Form} instance allowing a user to
|
||||||
@ -215,6 +224,10 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
function LinkForm() {
|
function LinkForm() {
|
||||||
|
$siteTree = new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle', true);
|
||||||
|
// mimic the SiteTree::getMenuTitle(), which is bypassed when the search is performed
|
||||||
|
$siteTree->setSearchFunction(array($this, 'siteTreeSearchCallback'));
|
||||||
|
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this->controller,
|
$this->controller,
|
||||||
"{$this->name}/LinkForm",
|
"{$this->name}/LinkForm",
|
||||||
@ -235,7 +248,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'),
|
'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'URLSegment', 'MenuTitle', true),
|
$siteTree,
|
||||||
new TextField('external', _t('HtmlEditorField.URL', 'URL'), 'http://'),
|
new TextField('external', _t('HtmlEditorField.URL', 'URL'), 'http://'),
|
||||||
new EmailField('email', _t('HtmlEditorField.EMAIL', 'Email address')),
|
new EmailField('email', _t('HtmlEditorField.EMAIL', 'Email address')),
|
||||||
new TreeDropdownField('file', _t('HtmlEditorField.FILE', 'File'), 'File', 'Filename', 'Title', true),
|
new TreeDropdownField('file', _t('HtmlEditorField.FILE', 'File'), 'File', 'Filename', 'Title', true),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user