BUG: Fixed SearchForm not calling getTemplate() in forTemplate()

This commit is contained in:
Stephen McMahon 2014-10-03 14:08:47 +10:00
parent 708e70624c
commit 9d888d5dde
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;