Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Readonly GridField Column

Go to End



Community Member, 1 Post

5 September 2013 at 6:26pm

I like to make a Column in a GridFiled readonly also in the following edit-form has same filed as readonly.
The idea is to show a list of cameras but name of camera and last frame were readonly.

Here is my code:

class CameraObject extends DataObject
public static $db = array(
'Publish' => "Enum('No, Yes', 'No')",

public static $has_one = array(

class CameraPage_Controller extends Page_Controller

static $allowed_actions = array('index', 'AllCameras');

public function init()

public function index(SS_HTTPRequest $request)
$this->Content = $this->AllCameras();
return $this->render();

public function AllCameras()
$records = CameraObject::get();

$config = GridFieldConfig::create()->addComponents(
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
new GridFieldPaginator(10),
new GridFieldEditButton(),
new GridFieldDetailForm()

$gridField = new GridField('cameras', 'Cameras', $records, $config);

$dataColumns = $config->getComponentByType('GridFieldDataColumns');
'Publish' => 'Publish',
'Name' => 'Name',
'Alias' => 'Alias',
'LastFrame' => 'LastFrame',

$form = new Form($this, "AllCameras", new FieldList($gridField), new FieldList());

return $form;