Merge pull request #1110 from stephenmcm/SearchFormPatch

BUG: Fixes #1107 SearchForm not calling getTemplate() in forTemplate()
This commit is contained in:
Damian Mooyman 2014-12-03 15:32:33 +13:00
commit 19f337b544
2 changed files with 28 additions and 3 deletions

View File

@ -59,11 +59,23 @@ class SearchForm extends Form {
$this->disableSecurityToken();
}
/**
* Return a rendered version of this form.
*
* This is returned when you access a form as $FormObject rather
* than <% with FormObject %>
*/
public function forTemplate() {
return $this->renderWith(array(
'SearchForm',
'Form'
$return = $this->renderWith(array_merge(
(array)$this->getTemplate(),
array('SearchForm', 'Form')
));
// Now that we're rendered, clear message
$this->clearMessage();
return $return;
}
/**

View File

@ -56,6 +56,19 @@ class ZZZSearchFormTest extends FunctionalTest {
return $supports;
}
public function testSearchFormTemplateCanBeChanged() {
if(!$this->checkFulltextSupport()) return;
$sf = new SearchForm($this->mockController, 'SearchForm');
$sf->setTemplate('BlankPage');
$this->assertContains(
'<body class="SearchForm Form RequestHandler BlankPage">',
$sf->forTemplate()
);
}
public function testPublishedPagesMatchedByTitle() {
if(!$this->checkFulltextSupport()) return;