mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
2820b503c2
commit
e4dbf8065b
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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',
|
||||||
|
Loading…
Reference in New Issue
Block a user