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

View File

@ -715,6 +715,19 @@ class FieldListTest extends SapphireTest {
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() {
$FieldList = new FieldList(
new TabSet('Root', new Tab('Main',