/** * Site search form */ public function SearchForm() { $searchText = _t('SearchForm.SEARCH', 'Search'); if ($this->owner->request && $this->owner->request->getVar('Search')) { $searchText = $this->owner->request->getVar('Search'); } $fields = new FieldList(new TextField('Search', false, $searchText)); $actions = new FieldList(new FormAction('results', _t('SearchForm.GO', 'Go'))); $form = SearchForm::create($this->owner, 'SearchForm', $fields, $actions); $form->classesToSearch(FulltextSearchable::get_searchable_classes()); return $form; }
/** * Site search form. * * Similar to ContentControllerSearchExtension::SearchForm() but * redirecting to a suitable page to avoid invalid URLs such as * 'adg/AdgEntity.html/SearchForm' * * The default redirection is to '/home/SearchForm' but can be * changed with GtkdocControllerSearcExtension::setSearchAction(). */ public function SearchForm() { if ($this->owner->request && $this->owner->request->getVar('Search')) { $searchText = $this->owner->request->getVar('Search'); } else { $searchText = _t('SearchForm.SEARCH', 'Search'); } $fields = new FieldList(new TextField('Search', false, $searchText)); $actions = new FieldList(new FormAction('results', _t('SearchForm.GO', 'Go'))); $form = new SearchForm($this->owner, 'SearchForm', $fields, $actions); $form->classesToSearch(FulltextSearchable::get_searchable_classes()); // The following line is the reason of this overriding: we must // redirect to a suitable page to avoid invalid URLs such as // 'adg/AdgEntity.html/SearchForm' $form->setFormAction(self::$search_action); return $form; }