mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #131 from halkyon/master
Nice debug formatting for ArrayList and DataList
This commit is contained in:
commit
99b2430565
@ -33,6 +33,15 @@ class ArrayList extends ViewableData implements SS_List {
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
public function debug() {
|
||||
$val = "<h2>" . $this->class . "</h2><ul>";
|
||||
foreach($this->toNestedArray() as $item) {
|
||||
$val .= "<li style=\"list-style-type: disc; margin-left: 20px\">" . Debug::text($item) . "</li>";
|
||||
}
|
||||
$val .= "</ul>";
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function toNestedArray() {
|
||||
$result = array();
|
||||
|
||||
|
@ -152,6 +152,15 @@ class DataList extends ViewableData implements SS_List {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function debug() {
|
||||
$val = "<h2>" . $this->class . "</h2><ul>";
|
||||
foreach($this->toNestedArray() as $item) {
|
||||
$val .= "<li style=\"list-style-type: disc; margin-left: 20px\">" . Debug::text($item) . "</li>";
|
||||
}
|
||||
$val .= "</ul>";
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function map($keyField = 'ID', $titleField = 'Title') {
|
||||
return new SS_Map($this, $keyField, $titleField);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user