Hello,
I am trying to add an image to a DataObject. Basically I have a Work page which has all the videos and videos page has a title, a url and an image to be uploaded. I can't seem to figure out how to add the image. Here is what I have so far:
<?php
class Video extends DataObject {
private static $db = array(
'VideoTitle' => 'Varchar',
'VideoURL' => 'Varchar'
);
private static $has_one = array(
'Work' => 'Work'
);
}
I also have a Work page which lists all the videos as follows:
<?php
class Work extends Page {
private static $has_many = array(
'Videos' => 'Video'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$config = GridFieldConfig_RelationEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
'VideoTitle' => 'Video Title',
'VideoURL' => "Video URL"
));
$studentsField = new GridField(
'Videos',
'All Videos',
$this->Videos(),
$config
);
$fields->addFieldToTab('Root.Videos', $studentsField);
return $fields;
}
}
class Work_Controller extends Page_Controller {
}
How can I allow the user to upload the image and in the grid field display the name of the image or even the image itself (which would be way better). Is this possible?