我在 Page.php 文件中定义了一个搜索表单
函数 AdvancedSearchForm() { $searchText = isset($this->Query) ?$this->Query : '搜索'; $searchText2 = isset($this->Subquery) ?$this->子查询:'0'; $searchText3 = isset($this->documentType) ?$this->documentType : '全部';
$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;
}
并且我的所有页面都是从 Page 扩展而来的,并且搜索表单位于标题中,因此出现在所有页面上。但是当用户在安全/登录页面上并尝试搜索某些内容时,他会收到以下错误消息
The action 'AdvancedSearchForm' does not exist in class Security
我认为这是因为安全页面没有从页面扩展。如何设置搜索,以便它可以在任何页面上工作,包括系统页面,例如安全登录页面?