/**
  * @return Form
  */
 public function SearchForm()
 {
     $form = new Form($this, 'SearchForm', $this->context->getFields(), new FieldList(FormAction::create('doSearch', _t('GridFieldExtensions.SEARCH', 'Search'))->setUseButtonTag(true)->addExtraClass('ss-ui-button')->setAttribute('data-icon', 'magnifier')));
     $form->addExtraClass('stacked add-existing-search-form');
     $form->setFormMethod('GET');
     return $form;
 }
 /**
  * returns the form
  * @return Form
  */
 public function getGoogleSiteSearchForm($name = "GoogleSiteSearchForm")
 {
     $formIDinHTML = "Form_" . $name;
     if ($page = GoogleCustomSearchPage::get()->first()) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
         Requirements::javascript('googlecustomsearch/javascript/GoogleCustomSearch.js');
         $apiKey = Config::inst()->get("GoogleCustomSearchExt", "api_key");
         $cxKey = Config::inst()->get("GoogleCustomSearchExt", "cx_key");
         if ($apiKey && $cxKey) {
             Requirements::customScript("\n\t\t\t\t\t\tGoogleCustomSearch.apiKey = '" . $apiKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.cxKey = '" . $cxKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.formSelector = '#" . $formIDinHTML . "';\n\t\t\t\t\t\tGoogleCustomSearch.inputFieldSelector = '#" . $formIDinHTML . "_search';\n\t\t\t\t\t\tGoogleCustomSearch.resultsSelector = '#" . $formIDinHTML . "_Results';\n\t\t\t\t\t", "GoogleCustomSearchExt");
             $form = new Form($this->owner, 'GoogleSiteSearchForm', new FieldList($searchField = new TextField('search'), $resultField = new LiteralField($name . "_Results", "<div id=\"" . $formIDinHTML . "_Results\"></div>")), new FieldList(new FormAction('doSearch', _t("GoogleCustomSearchExt.GO", "Full Results"))));
             $form->setFormMethod('GET');
             if ($page = GoogleCustomSearchPage::get()->first()) {
                 $form->setFormAction($page->Link());
             }
             $form->disableSecurityToken();
             $form->loadDataFrom($_GET);
             $searchField->setAttribute("autocomplete", "off");
             $form->setAttribute("autocomplete", "off");
             return $form;
         } else {
             user_error("You must set an API Key and a CX key in your configs to use the Google Custom Search Form", E_USER_NOTICE);
         }
     } else {
         user_error("You must create a GoogleCustomSearchPage first.", E_USER_NOTICE);
     }
 }
 public function Form()
 {
     $fields = new FieldList(new TextField('Name'), new EmailField('Email'), new TextareaField('Message'));
     $actions = new FieldList(new FormAction('submit', 'Submit'));
     $form = new Form($this, 'form', $fields, $actions);
     $form->setFormAction('/blocks/form');
     $form->setFormMethod('POST');
     return $form;
 }
 public function ContactForm()
 {
     $fields = new FieldList(TextField::create('Name', 'Name*')->setAttribute('placeholder', 'Your Name'), EmailField::create('Email', 'Email*')->setAttribute('placeholder', 'Your Email'), TextField::create('Phone', 'Phone')->setAttribute('placeholder', '555-555-5555'), TextField::create('Required', 'Leave this field blank', ''), TextareaField::create('Comments', 'Comments*')->setAttribute('placeholder', 'Comments'));
     $actions = new FieldList(FormAction::create("doSubmitForm", 'Send'));
     $required = new RequiredFields('Name', 'Email', 'Comments');
     $form = new Form($this, 'ContactForm', $fields, $actions, $required);
     $form->setFormMethod('POST', true);
     return $form;
 }
 function Form()
 {
     $query = $this->request->getVar("search");
     $fields = new FieldList(new TextField("search", "", $query));
     $actions = new FieldList($searchaction = new FormAction("index", "Search"));
     $searchaction->setFullAction(null);
     $form = new Form($this, "SearchForm", $fields, $actions);
     $form->setFormAction($this->Link());
     $form->setFormMethod("GET");
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * Return a form which sends the user to the first results page. If you want
  * to customize this form, use your own extension and apply that to the
  * page.
  *
  * @return Form
  */
 public function getGoogleSiteSearchForm()
 {
     if ($page = GoogleSiteSearchPage::get()->first()) {
         $label = Config::inst()->get('GoogleSiteSearchDefaultFormExtension', 'submit_button_label');
         $formLabel = Config::inst()->get('GoogleSiteSearchDefaultFormExtension', 'input_label');
         $form = new Form($this, 'GoogleSiteSearchForm', new FieldList(new TextField('Search', $formLabel)), new FieldList(new FormAction('doSearch', $label)));
         $form->setFormMethod('GET');
         $form->setFormAction($page->Link());
         $form->disableSecurityToken();
         $form->loadDataFrom($_GET);
         return $form;
     }
 }
 /**
  * @param Controller $controller
  * @param string $back_url
  * @return Form
  */
 public static function buildLoginForm(Controller $controller, $back_url = '')
 {
     if (!defined('OPENSTACKID_ENABLED') || OPENSTACKID_ENABLED == false) {
         $form = MemberAuthenticator::get_login_form($controller);
         return $form;
     } else {
         $back_url = OpenStackIdCommon::cleanBackUrl($back_url);
         $form = new Form($controller, 'OpenStackIdLoginForm', $fields = new FieldList(), $actions = new FieldList(array(new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")))));
         $form->addExtraClass('form-fieldless');
         $form->setFormAction("/Security/login?BackURL={$back_url}");
         $form->setFormMethod('post');
         return $form;
     }
 }
 public function SearchForm()
 {
     $searchText = '';
     if ($this->request && $this->request->getVar('Search')) {
         $searchText = $this->request->getVar('Search');
     }
     $queryField = new TextField('Search', FALSE, $searchText);
     $queryField->setAttribute('placeholder', 'Search news');
     $fields = new FieldList($queryField);
     $actions = new FieldList(new FormAction('results', 'Search'));
     $form = new Form($this, 'SearchForm', $fields, $actions);
     $form->setFormMethod('get');
     $form->disableSecurityToken();
     return $form;
 }
 public function SearchForm()
 {
     $searchText = $this->GetSearchTerm() ?: "";
     $queryType = $this->GetSearchType() ?: "";
     $category = $this->GetCategory() ?: "";
     $searchField = new TextField('Search', "Search youtube for:", $searchText);
     $searchField->setAttribute('placeholder', "Type here");
     $fields = new FieldList(new DropdownField('queryType', "Search type:", array('relevance' => 'All Videos', 'viewcount' => 'Most Viewed Videos', 'date' => 'Most recent', 'rating' => 'Top rated'), $queryType), new DropdownField('category', "Category:", $this->GetCategories(), $category), $searchField);
     $action = new FormAction('YouTubeSearchResults', _t('SearchForm.GO', 'Go'));
     $action->addExtraClass('btn btn-default btn-search');
     $action->useButtonTag = true;
     $action->setButtonContent('<i class="fa fa-search"></i><span class="text-hide">Search</span>');
     $actions = new FieldList($action);
     $form = new Form($this, 'YouTubeSearchForm', $fields, $actions);
     $form->setFormMethod('GET');
     $form->setFormAction($this->Link() . "");
     $form->disableSecurityToken();
     return $form;
 }
Example #10
0
 /**
  * Form used to filter the sitetree. It can only be used via javascript for now.
  * 
  * @return Form
  */
 function SearchTreeForm()
 {
     // get all page types in a dropdown-compatible format
     $pageTypes = SiteTree::page_type_classes();
     array_unshift($pageTypes, 'All');
     $pageTypes = array_combine($pageTypes, $pageTypes);
     asort($pageTypes);
     // get all filter instances
     $filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
     $filterMap = array();
     // remove base class
     array_shift($filters);
     // add filters to map
     foreach ($filters as $filter) {
         $filterMap[$filter] = call_user_func(array($filter, 'title'));
     }
     // ensure that 'all pages' filter is on top position
     uasort($filterMap, create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;'));
     $showDefaultFields = array();
     $form = new Form($this, 'SearchTreeForm', new FieldSet($showDefaultFields[] = new DropdownField('FilterClass', _t('CMSMain.SearchTreeFormPagesDropdown', 'Pages'), $filterMap), $showDefaultFields[] = new TextField('Title', _t('CMSMain.TITLEOPT', 'Title')), new TextField('Content', 'Text'), new DateField('EditedSince', _t('CMSMain_left.ss.EDITEDSINCE', 'Edited Since')), new DropdownField('ClassName', 'Page Type', $pageTypes, null, null, 'Any'), new TextField('MenuTitle', _t('CMSMain.MENUTITLEOPT', 'Navigation Label')), new TextField('Status', _t('CMSMain.STATUSOPT', 'Status')), new TextField('MetaDescription', _t('CMSMain.METADESCOPT', 'Description')), new TextField('MetaKeywords', _t('CMSMain.METAKEYWORDSOPT', 'Keywords'))), new FieldSet(new ResetFormAction('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')), new FormAction('doSearchTree', _t('CMSMain_left.ss.SEARCH', 'Search'))));
     $form->setFormMethod('GET');
     $form->disableSecurityToken();
     $form->unsetValidator();
     foreach ($showDefaultFields as $f) {
         $f->addExtraClass('show-default');
     }
     return $form;
 }
 public function SearchForm()
 {
     if ($this->modelClass != 'All') {
         $context = singleton($this->modelClass)->getDefaultSearchContext();
         $fields = $context->getSearchFields();
     } else {
         $fields = new FieldSet();
     }
     $fields->push(new DropdownField('State', 'State', array('unapproved' => 'Awaiting Moderation', 'approved' => 'Approved', 'spam' => 'Marked as Spam'), 'unapproved'));
     $fields->push(new HiddenField('Page', 'Page', 0));
     $form = new Form($this, "SearchForm", $fields, new FieldSet(new FormAction('search', _t('MemberTableField.SEARCH', 'Search')), $clearAction = new ResetFormAction('clearsearch', _t('ModelAdmin.CLEAR_SEARCH', 'Clear Search'))));
     $form->setFormMethod('get');
     $form->setHTMLID("Form_SearchForm_" . $this->modelClass);
     $clearAction->useButtonTag = true;
     $clearAction->addExtraClass('minorAction');
     return $form;
 }
 /**
  * Return a search form that contains the original search criteria.
  *
  * Should be extended to include the filters and facets needed in your 
  * context.
  *
  * @return Form
  */
 public function FulltextSearchForm()
 {
     $params = $this->getSearchParams();
     $fields = new FieldList(new TextField('q', ''));
     $form = new Form($this, 'SearchForm', $fields, new FieldList(new FormAction('search', 'Search')));
     $form->loadDataFrom($params);
     $form->setFormMethod('get');
     $form->disableSecurityToken();
     $form->setFormAction($this->Link());
     return $form;
 }
 /**
  * Get a search form for a single {@link DataObject} subclass.
  * 
  * @return Form
  */
 public function SearchForm()
 {
     $context = singleton($this->modelClass)->getDefaultSearchContext();
     $fields = $context->getSearchFields();
     $columnSelectionField = $this->ColumnSelectionField();
     $fields->push($columnSelectionField);
     $validator = new RequiredFields();
     $validator->setJavascriptValidationHandler('none');
     $form = new Form($this, "SearchForm", $fields, new FieldSet(new FormAction('search', _t('MemberTableField.SEARCH', 'Search')), $clearAction = new ResetFormAction('clearsearch', _t('ModelAdmin.CLEAR_SEARCH', 'Clear Search'))), $validator);
     //$form->setFormAction(Controller::join_links($this->Link(), "search"));
     $form->setFormMethod('get');
     $form->setHTMLID("Form_SearchForm_" . $this->modelClass);
     $form->disableSecurityToken();
     $clearAction->useButtonTag = true;
     $clearAction->addExtraClass('minorAction');
     return $form;
 }
 /**
  * Documentation Basic Search Form
  *
  * Integrates with sphinx
  * @return Form
  */
 function DocumentationSearchForm()
 {
     if (!DocumentationSearch::enabled()) {
         return false;
     }
     $query = isset($_REQUEST['Search']) ? Convert::raw2xml($_REQUEST['Search']) : "";
     $fields = new FieldSet(new TextField('Search', _t('DocumentationViewer.SEARCH', 'Search'), $query));
     $actions = new FieldSet(new FormAction('results', 'Search'));
     $form = new Form($this, 'DocumentationSearchForm', $fields, $actions);
     $form->disableSecurityToken();
     $form->setFormMethod('get');
     $form->setFormAction(self::$link_base . 'DocumentationSearchForm');
     return $form;
 }
 /**
  * Create Extension search form based on type of Extension.
  *
  * @return boolean $form
  */
 public function extensionSearch()
 {
     $context = singleton('ExtensionData')->getCustomSearchContext();
     $fields = $context->getSearchFields();
     $form = new Form($this, "extensionSearch", $fields, new FieldList(new FormAction('doSearch', "Search {$this->extensionType}")));
     $form->setFormMethod('GET');
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * @return Form
  */
 public function DateRangeForm()
 {
     $fields = new FieldList($dateFrom = new DateField('from'), $dateTo = new DateField('to'), new HiddenField('tag'));
     $dateFrom->setConfig('showcalendar', true);
     $dateTo->setConfig('showcalendar', true);
     $actions = new FieldList(FormAction::create("doDateFilter")->setTitle("Filter")->addExtraClass('btn btn-primary primary'), FormAction::create("doDateReset")->setTitle("Clear")->addExtraClass('btn'));
     $form = new Form($this, 'DateRangeForm', $fields, $actions);
     $form->loadDataFrom($this->request->getVars());
     $form->setFormMethod('get');
     // Manually extract the message so we can clear it.
     $form->ErrorMessage = $form->Message();
     $form->ErrorMessageType = $form->MessageType();
     $form->clearMessage();
     return $form;
 }
 public function SearchForm()
 {
     $context = singleton($this->otherClass)->getDefaultSearchContext();
     $fields = $context->getSearchFields();
     $form = new Form($this, 'SearchForm', $fields, new FieldSet(new FormAction('Search', _t('MemberTableField.SEARCH', 'Search')), new ResetFormAction('ClearSearch', _t('ModelAdmin.CLEAR_SEARCH', 'Clear Search'))));
     $form->setFormMethod('get');
     return $form;
 }
Example #18
0
 /**
  * @return Form
  */
 function VersionsForm()
 {
     $pageID = $this->request->requestVar('ID') ? $this->request->requestVar('ID') : $this->currentPageID();
     $page = $this->getRecord($pageID);
     if ($page) {
         $versions = $page->allVersions($this->request->requestVar('ShowUnpublished') ? "" : "\"SiteTree\".\"WasPublished\" = 1");
         // inject link to cms
         if ($versions) {
             foreach ($versions as $k => $version) {
                 $version->CMSLink = sprintf('%s/%s/%s', $this->Link('getversion'), $version->ID, $version->Version);
             }
         }
         $vd = new ViewableData();
         $versionsHtml = $vd->customise(array('Versions' => $versions))->renderWith('CMSMain_versions');
     } else {
         $versionsHtml = '';
     }
     $form = new Form($this, 'VersionsForm', new FieldSet(new CheckboxField('ShowUnpublished', _t('CMSMain_left.ss.SHOWUNPUB', 'Show unpublished versions')), new LiteralField('VersionsHtml', $versionsHtml), new HiddenField('ID', false, $pageID), new HiddenField('Locale', false, $this->Locale)), new FieldSet(new FormAction('versions', _t('CMSMain.BTNREFRESH', 'Refresh')), new FormAction('compareversions', _t('CMSMain.BTNCOMPAREVERSIONS', 'Compare Versions'))));
     $form->loadDataFrom($this->request->requestVars());
     $form->setFormMethod('GET');
     $form->unsetValidator();
     return $form;
 }
Example #19
0
 /**
  * @return Form
  */
 function SyncForm()
 {
     $form = new Form($this, 'SyncForm', new FieldSet(), new FieldSet($btn = new FormAction('doSync', _t('FILESYSTEMSYNC', 'Look for new files'))));
     $form->addExtraClass('actionparams');
     $form->setFormMethod('GET');
     $form->setFormAction('dev/tasks/FilesystemSyncTask');
     $btn->describe(_t('AssetAdmin_left.ss.FILESYSTEMSYNC_DESC', 'SilverStripe maintains its own database of the files &amp; images stored in your assets/ folder.  Click this button to update that database, if files are added to the assets/ folder from outside SilverStripe, for example, if you have uploaded files via FTP.'));
     return $form;
 }
Example #20
0
 /**
  * Returns a form for filtering of files and assets gridfield.
  * Result filtering takes place in {@link getList()}.
  *
  * @return Form
  * @see AssetAdmin.js
  */
 public function SearchForm()
 {
     $folder = $this->currentPage();
     $context = $this->getSearchContext();
     $fields = $context->getSearchFields();
     $actions = new FieldList(FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Apply Filter'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.RESET', 'Reset')));
     $form = new Form($this, 'filter', $fields, $actions);
     $form->setFormMethod('GET');
     $form->setFormAction(Controller::join_links($this->Link('show'), $folder->ID));
     $form->addExtraClass('cms-search-form');
     $form->loadDataFrom($this->getRequest()->getVars());
     $form->disableSecurityToken();
     // This have to match data-name attribute on the gridfield so that the javascript selectors work
     $form->setAttribute('data-gridfield', 'File');
     return $form;
 }
Example #21
0
 public function Form()
 {
     $form = new Form($this, 'Form', new FieldList(new EmailField('Email')), new FieldList(new FormAction('doSubmit')));
     $form->setFormMethod('POST');
     $form->setStrictFormMethodCheck(true);
     $form->disableSecurityToken();
     // Disable CSRF protection for easier form submission handling
     return $form;
 }
 public function RegistryFilterForm()
 {
     $singleton = $this->dataRecord->getDataSingleton();
     if (!$singleton) {
         return;
     }
     $fields = $singleton->getSearchFields();
     // Add the sort information.
     $vars = $this->getRequest()->getVars();
     $fields->merge(new FieldList(new HiddenField('Sort', 'Sort', !$vars || empty($vars['Sort']) ? 'ID' : $vars['Sort']), new HiddenField('Dir', 'Dir', !$vars || empty($vars['Dir']) ? 'ASC' : $vars['Dir'])));
     $actions = new FieldList(FormAction::create('doRegistryFilter')->setTitle('Filter')->addExtraClass('btn btn-primary primary'), FormAction::create('doRegistryFilterReset')->setTitle('Clear')->addExtraClass('btn'));
     $form = new Form($this, 'RegistryFilterForm', $fields, $actions);
     $form->loadDataFrom($this->request->getVars());
     $form->disableSecurityToken();
     $form->setFormMethod('get');
     return $form;
 }
Example #23
0
 /**
  * @return Form
  */
 public function SearchForm()
 {
     $context = $this->getSearchContext();
     $form = new Form($this, "SearchForm", $context->getSearchFields(), new FieldList(Object::create('FormAction', 'search', _t('MemberTableField.APPLY_FILTER', 'Apply Filter'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clearsearch', _t('ModelAdmin.RESET', 'Reset'))->setUseButtonTag(true)), new RequiredFields());
     $form->setFormMethod('get');
     $form->setFormAction($this->Link($this->sanitiseClassName($this->modelClass)));
     $form->addExtraClass('cms-search-form');
     $form->disableSecurityToken();
     $form->loadDataFrom($this->request->getVars());
     $this->extend('updateSearchForm', $form);
     return $form;
 }
 public function AddonsSearchForm()
 {
     $form = new Form($this, 'AddonsSearchForm', new FieldList(array(TextField::create('search', 'Search for')->setValue($this->request->getVar('search'))->addExtraClass('input-block-level'), DropdownField::create('sort', 'Sort by')->setSource(array('name' => 'Name', 'downloads' => 'Most downloaded', 'newest' => 'Newest'))->setEmptyString('Best match')->setValue($this->request->getVar('sort'))->addExtraClass('input-block-level'), DropdownField::create('type', 'Add-on type')->setSource(array('module' => 'Modules', 'theme' => 'Themes'))->setEmptyString('Modules and themes')->setValue($this->request->getVar('type'))->addExtraClass('input-block-level'), CheckboxSetField::create('compatibility', 'Compatible SilverStripe versions')->setSource(SilverStripeVersion::get()->map('Name', 'Name'))->setValue($this->request->getVar('compatibility'))->setTemplate('AddonsSearchCheckboxSetField'))), new FieldList());
     return $form->setFormMethod('GET')->setFormAction($this->Link());
 }