当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchForm::create方法代码示例

本文整理汇总了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;
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:15,代码来源:ContentControllerSearchExtension.php

示例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;
 }
开发者ID:nglasl,项目名称:silverstripe-extensible-search,代码行数:43,代码来源:ExtensibleSearchPage.php

示例3: SearchForm

 public function SearchForm()
 {
     return SearchForm::create($this, "SearchForm");
 }
开发者ID:andrelohmann,项目名称:roof-for-refugees.org,代码行数:4,代码来源:FindController.php


注:本文中的SearchForm::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。