Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Understanding the SearchForm Method

Go to End

6 Posts   2421 Views


Community Member, 51 Posts

18 June 2010 at 12:13pm

Edited: 18/06/2010 12:15pm

Can someone please explain how to extend the SearchForm class.

My aim is to modify the default text and button text initially, but will probably extend to more changes later.

I have located the function in this file " \saphire\search\ContentControllerExtension.php"

The easy thing to do would be to make the changes in this file. But messing with the core files is not ideal of course.

I have tried extending the Searchform.php class as follows:

Create new class "SiteSearch.php" in mycode

class SiteSearch extends SearchForm {

		function __construct($controller,$name){



Putting $SiteSearch in my template and I get the default form rendering OK. But I get the error below.

Any help would be much appreciated.

[User Error] Uncaught Exception: Object->__call(): the method 'getviewer' does not exist on 'DataObjectSet'
GET /home/SiteSearch?Search=&action_getResults=Go

Line 724 in E:\websites\IRIS\v2\sapphire\core\Object.php

716 				default :
717 					throw new Exception (
718 						"Object->__call(): extra method $method is invalid on $this->class:" . var_export($config, true)
719 					);
720 			}
721 		} else {
722 			// Please do not change the exception code number below.
724 			throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
725 		}
726 	}
728 	// -----------------------------------------------------------------------------------------------------------------
730 	/**


    * Object->__call(getViewer,Array)
    * DataObjectSet->getViewer(SiteSearch)
      Line 155 of Controller.php
    * Controller->handleRequest(SS_HTTPRequest)
      Line 199 of ContentController.php
    * ContentController->handleRequest(SS_HTTPRequest)
      Line 67 of ModelAsController.php
    * ModelAsController->handleRequest(SS_HTTPRequest)
      Line 283 of Director.php
    * Director::handleRequest(SS_HTTPRequest,Session)
      Line 127 of Director.php
    * Director::direct(home/SiteSearch)
      Line 127 of main.php


Forum Moderator, 5523 Posts

18 June 2010 at 3:47pm

If you want to override the search form (well the button and the text copy the content from the ContentControlellerExtension class to your Page.php then you can customize it as much as you wish.


Community Member, 51 Posts

18 June 2010 at 7:33pm

Thanks Willr. I think the penny has dropped here! I am kicking myself right now!

Much appreciated!


Community Member, 52 Posts

9 July 2010 at 7:36pm

Thank you for posting this! There are a lot of conflicting posts and this one finally answers how to customise the search form and button in 2.4



Community Member, 2 Posts

3 August 2010 at 7:25pm

It is too good


Community Member, 2 Posts

3 August 2010 at 7:26pm

It is too good