silverstripe-docsviewer/code/forms/DocumentationSearchForm.php
Cam Findlay 410312c641 Pass the current version to the search
From a UX POV, when I'm searching docs I'm likely to be working on a site of a specific version - results of docs from older or newer versions are likely to be less relevant to me. If I want to search wider after my initial search I can use the check boxes on the advanced search.
2014-12-17 11:18:00 +13:00

38 lines
862 B
PHP

<?php
class DocumentationSearchForm extends Form {
public function __construct($controller) {
$fields = new FieldList(
TextField::create('q', _t('DocumentationViewer.SEARCH', 'Search'), '')
->setAttribute('placeholder', _t('DocumentationViewer.SEARCH', 'Search'))
);
$page = $controller->getPage();
if($page){
$versions = HiddenField::create(
'Versions',
_t('DocumentationViewer.VERSIONS', 'Versions'),
$page->getEntity()->getVersion()
);
$fields->push($versions);
}
$actions = new FieldList(
new FormAction('results', _t('DocumentationViewer.SEARCH', 'Search'))
);
parent::__construct($controller, 'DocumentationSearchForm', $fields, $actions);
$this->disableSecurityToken();
$this->setFormMethod('GET');
$this->setFormAction($controller->Link('results'));
$this->addExtraClass('search');
}
}