Merge pull request #54 from camfindlay/curentversionsearch

Pass the current version to the search
This commit is contained in:
Will Rossiter 2015-01-07 14:11:40 +13:00
commit 653a2c87f4
1 changed files with 17 additions and 10 deletions

View File

@ -3,18 +3,25 @@
class DocumentationSearchForm extends Form {
public function __construct($controller) {
$versions = HiddenField::create(
'Versions',
_t('DocumentationViewer.VERSIONS', 'Versions'),
implode(',', $controller->getManifest()->getAllVersions())
);
$fields = new FieldList(
TextField::create('q', _t('DocumentationViewer.SEARCH', 'Search'), '')
->setAttribute('placeholder', _t('DocumentationViewer.SEARCH', 'Search')),
$versions
->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'))
);
@ -24,7 +31,7 @@ class DocumentationSearchForm extends Form {
$this->disableSecurityToken();
$this->setFormMethod('GET');
$this->setFormAction($controller->Link('results'));
$this->addExtraClass('search');
}
}
}