silverstripe-gridfieldexten.../src/GridFieldTitleHeader.php

33 lines
730 B
PHP
Raw Normal View History

<?php
2017-06-16 06:07:09 +02:00
namespace Symbiote\GridFieldExtensions;
2016-11-29 18:20:15 +01:00
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ArrayData;
/**
* A simple header which displays column titles.
*/
2016-12-21 03:34:58 +01:00
class GridFieldTitleHeader implements GridField_HTMLProvider
{
public function getHTMLFragments($grid)
{
$cols = ArrayList::create();
2016-12-21 03:34:58 +01:00
foreach ($grid->getColumns() as $name) {
$meta = $grid->getColumnMetadata($name);
$cols->push(ArrayData::create(array(
2016-12-21 03:34:58 +01:00
'Name' => $name,
'Title' => $meta['title']
)));
}
return array(
'header' => $cols->renderWith(__CLASS__)
);
}
}