Browse files

API CHANGE: Added FieldList::forTemplate(), so that by default a Fiel…

…dList will be rendered in its template as a concatenation of FieldHolder values.

API CHANGE: Removed unnecessary HiddenFieldList class.
  • Loading branch information...
1 parent 2820b50 commit e4dbf8065b671b1c000d8482d495b2694678f023 @sminnee sminnee committed Mar 7, 2012
Showing with 17 additions and 11 deletions.
  1. +4 −11 forms/FieldList.php
  2. +13 −0 tests/forms/FieldListTest.php
View
15 forms/FieldList.php
@@ -538,21 +538,14 @@ function fieldPosition($field) {
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
13 tests/forms/FieldListTest.php
@@ -715,6 +715,19 @@ function testFieldPosition() {
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',

0 comments on commit e4dbf80

Please sign in to comment.