Hello, I 'm following the tutorials from SilverStripe website, and I added a page on the CMS to upload images .
I have two problems :
the first is when I upload the picture, and try to return to the previus page, the CMS goes blank and I have to refresh to see the content again .
The other is that when I add multiple pictures with
$ uploader- > setAllowedMaxFileNumber ( 20);
only the last I've added is saved.
I hope you can help me, I 'm starting .
Thank you!
Proyecto.php
class Proyecto extends Page {
..
private static $has_many = array(
'Galeria' => 'GaleriaProyecto'
);
public function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Galeria', GridField::create(
'Galeria',
'Imagenes del proyecto',
$this->Galeria(),
GridFieldConfig_RecordEditor::create()
));
return $fields;
}
}
class Proyecto_Controller extends Page_Controller {}
GaleriaProyecto.php
class GaleriaProyecto extends dataObject {
private static $has_one = array(
'Imagen' => 'Image',
'Proyecto' => 'Proyecto'
);
private static $summary_fields = array(
'Imagen.CMSThumbnail' => ''
);
public function getCMSFields() {
$fields = FieldList::create(
$uploader = UploadField::create('Imagen')
);
$uploader -> setFolderName('Galeria');
$uploader->setAllowedMaxFileNumber(20);
$uploader -> getValidator()->setAllowedExtensions(array('png','jpg','jpeg','gif'));
return $fields;
}
}