Version: current

     1 <?php
     2
     3 class ProductSearchFormExtension extends Extension {
     4     function extraStatics() {}
     5
     6     function ProductSearchForm() {
     7         return $this->owner->SiteSearchForm();
     8     }
     9
    10     function SiteSearchForm($extra=null) {
    11         if ($searchPage = DataObject::get_one('ProductSearchPage')) {
    12             $controller = ModelAsController::controller_for($searchPage);
    13             // берем сокращенную форму для отображения на всех страницах сайта
    14             $current = ProductSearchPage::get_show_full_search_form();
    15             ProductSearchPage::set_show_full_search_form(false);
    16             $form = $controller->ProductSearchForm();
    17             ProductSearchPage::set_show_full_search_form($current);
    18
    19             $form->setTemplate('SiteProductSearch');
    20             $form->getValidator()->setJavascriptValidationHandler('none');
    21             $htmlID = 'SiteSearch';
    22             if ($extra) {
    23                 $form->addExtraClass($extra);
    24                 $htmlID .= "_{$extra}";
    25             }
    26             $form->setHTMLID($htmlID);
    27             if ($this->owner->getRequest()) {
    28                 $form->loadDataFrom($this->owner->getRequest()->requestVars());
    29             }
    30             return $form;
    31         } else {
    32             user_error('Create ProductSearchPage first');
    33         }
    34
    35     }
    36 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -