本文整理汇总了PHP中SearchForm::create方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm::create方法的具体用法?PHP SearchForm::create怎么用?PHP SearchForm::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchForm
的用法示例。
在下文中一共展示了SearchForm::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SearchForm
/**
* 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;
}
示例2: getForm
/**
* Instantiate the search form.
*
* @parameter <{REQUEST}> ss http request
* @parameter <{DISPLAY_SORTING}> boolean
* @return search form
*/
public function getForm($request = null, $sorting = true)
{
// Determine whether a search engine has been selected.
$engine = $this->data()->SearchEngine;
$configuration = Config::inst();
$classes = $configuration->get('FulltextSearchable', 'searchable_classes');
if (!$engine || $engine !== 'Full-Text' && !ClassInfo::exists($engine) || $engine === 'Full-Text' && (!is_array($classes) || count($classes) === 0)) {
// The search engine has not been selected.
return null;
}
// Determine whether the request has been passed through.
if (is_null($request)) {
$request = $this->getRequest();
}
// Display the search.
$fields = FieldList::create(TextField::create('Search', 'Search', $request->getVar('Search'))->addExtraClass('extensible-search')->setAttribute('data-suggestions-enabled', $configuration->get('ExtensibleSearchSuggestion', 'enable_suggestions') ? 'true' : 'false')->setAttribute('data-extensible-search-page', $this->data()->ID));
// Determine whether sorting has been passed through from the template.
if (is_string($sorting)) {
$sorting = $sorting === 'true';
}
// Determine whether to display the sorting selection.
if ($sorting) {
// Display the sorting selection.
$fields->push(DropdownField::create('SortBy', 'Sort By', $this->data()->getSelectableFields(), $request->getVar('SortBy') ? $request->getVar('SortBy') : $this->data()->SortBy)->setHasEmptyDefault(true));
$fields->push(DropdownField::create('SortDirection', 'Sort Direction', array('DESC' => 'Descending', 'ASC' => 'Ascending'), $request->getVar('SortDirection') ? $request->getVar('SortDirection') : $this->data()->SortDirection)->setHasEmptyDefault(true));
}
// Instantiate the search form.
$form = SearchForm::create($this, 'getForm', $fields, FieldList::create(FormAction::create('getSearchResults', 'Go')));
// When using the full-text search engine, the classes to search needs to be initialised.
if ($engine === 'Full-Text') {
$form->classesToSearch($classes);
}
// Allow extension customisation.
$this->extend('updateExtensibleSearchForm', $form);
return $form;
}
示例3: SearchForm
public function SearchForm()
{
return SearchForm::create($this, "SearchForm");
}