Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms Silverstripe-通用搜索表单不';无法在安全/登录页面上工作_Forms_Search_Silverstripe - Fatal编程技术网

Forms Silverstripe-通用搜索表单不';无法在安全/登录页面上工作

Forms Silverstripe-通用搜索表单不';无法在安全/登录页面上工作,forms,search,silverstripe,Forms,Search,Silverstripe,我在Page.php文件中定义了一个searchform 函数AdvancedSearchForm(){ $searchText=isset($this->Query)?$this->Query:'Search'; $searchText2=isset($this->Subquery)?$this->Subquery:'0'; $searchText3=isset($this->documentType)?$this->documentType:'All' $searchSections = D

我在Page.php文件中定义了一个searchform

函数AdvancedSearchForm(){ $searchText=isset($this->Query)?$this->Query:'Search'; $searchText2=isset($this->Subquery)?$this->Subquery:'0'; $searchText3=isset($this->documentType)?$this->documentType:'All'

$searchSections = DataObject::get('SearchSection');
$ss = array();
foreach ($searchSections as $section) {
    $ss[$section->ID] = $section->Name;
}

$fileTypes = DataObject::get('FileType');
$ft = array();
foreach ($fileTypes as $type) {
    $ft[$type->ID] = $type->Name;
}
$ft[0] = 'All';
ksort($ft);

$fields = new FieldSet(
    new TextField('Query','Keywords', $searchText),
    new DropdownField('Subquery', '', $ss, $searchText2),
    new DropdownField('documentType', '', $ft, $searchText3)
);
$actions = new FieldSet(
    new FormAction('AdvancedSearchResults', 'Search')
);
$form = new Form($this->owner, 'AdvancedSearchForm', $fields, $actions);
$form->setFormMethod('GET');
$form->setTemplate('Includes/SearchForm');
$form->disableSecurityToken();

return $form;
}

我的所有页面都是从页面扩展而来的,搜索表单位于页眉中,因此会显示在所有页面上。但当用户在安全/登录页面上尝试搜索某个内容时,他会收到以下错误消息

The action 'AdvancedSearchForm' does not exist in class Security

我认为这是因为安全页面没有从页面扩展。如何从中设置搜索,使其在任何页面(包括系统页面,如安全登录页面)上工作?

由于表单未传递给所需的控制器(~page\u controller),因此出现错误

定义表单对象时,应该测试$this->owner,看看它是否是Page\u控制器的后代。如果没有,您可以使用类似的方法,并使用$controller作为表单对象创建中的第一个变量

$sitetree_object = SiteTree::get_by_link('some-page-url');
$controller = ModelAsController::controller_for($sitetree_object);

但我必须将
ModelController
更改为
ModelAsController