API CHANGE: Added FieldList::forTemplate(), so that by default a FieldList will be rendered in its template as a concatenation of FieldHolder values.

API CHANGE: Removed unnecessary HiddenFieldList class.
This commit is contained in:
Sam Minnee 2012-03-08 10:00:54 +13:00
parent 2820b503c2
commit e4dbf8065b
2 changed files with 17 additions and 11 deletions

View File

@ -538,21 +538,14 @@ class FieldList extends ArrayList {
return false; return false;
} }
}
/** /**
* A field list designed to store a list of hidden fields. When inserted into a template, only the * Default template rendering of a FieldList will concatenate all FieldHolder values.
* input tags will be included */
*
* @package forms
* @subpackage fields-structural
*/
class HiddenFieldList extends FieldList {
function forTemplate() { function forTemplate() {
$output = ""; $output = "";
foreach($this as $field) { foreach($this as $field) {
$output .= $field->Field(); $output .= $field->FieldHolder();
} }
return $output; return $output;
} }

View File

@ -715,6 +715,19 @@ class FieldListTest extends SapphireTest {
unset($set); unset($set);
} }
/**
* FieldList::forTemplate() returns a concatenation of FieldHolder values.
*/
function testForTemplate() {
$set = new FieldList(
$a = new TextField('A'),
$b = new TextField('B')
);
$this->assertEquals($a->FieldHolder() . $b->FieldHolder(), $set->forTempalte());
}
function testMakeFieldReadonly() { function testMakeFieldReadonly() {
$FieldList = new FieldList( $FieldList = new FieldList(
new TabSet('Root', new Tab('Main', new TabSet('Root', new Tab('Main',