Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Readonly GridField Column

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 571 Views
  • keyvan
    Community Member
    1 Post

    Readonly GridField Column Link to this post

    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;

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.