12/03/2017 5:29pm

PHP | Problem -


<?php 


class Restaurant extends DataObject {
private static $db = array (
'Titel' => 'Varchar(255)',
'Beskrivelse' => 'Varchar(255)'
);

private static $has_one = array (
'HomePage' => 'HomePage',
'Photo' => 'Image'
);

private static $has_many = array (
'Starters' => 'Starter'
);

private static $summary_fields = array(
'GridThumbnail' => 'Logo',
'Titel' => 'Restaurants navn',
'Beskrivelse' => 'Beskrivelse'
);

public function GridThumbnail()
{
if ($this->Photo()->exists()) {
return $this->Photo()->SetWidth(100);
}

return '(Intet logo)';
}

public function getCMSFields()
{
$fields = FieldList::create(
TextField::create('Titel'),
TextField::create('Beskrivelse'),
$logos = UploadField::create('Photo', 'Logo')
);

$logos->setFolderName('restaurant-logoer');
$logos->getValidator()->setAllowedExtensions(array(
'png', 'svg'
));

$fields->addFieldToTab('Root.Starters', GridField::create(
'Starters',
'Starters',
$this->Starters(),
GridFieldConfig_RelationEditor::create()
));

return $fields;
}
}