diff --git a/code/forms/DocumentationSearchForm.php b/code/forms/DocumentationSearchForm.php index a08d705..17c1241 100644 --- a/code/forms/DocumentationSearchForm.php +++ b/code/forms/DocumentationSearchForm.php @@ -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'); } -} \ No newline at end of file +}