i try to use onAfterWrite()
<?php
class ProduktKolory extends DataObject {
static $db = array(
'Nazwa' => 'Varchar',
'URL' => 'Varchar'
);
static $has_one = array(
'Produkt' => 'Produkt',
'Kolor' => 'ModulKolory'
);
public function getCMSFields_forPopup() {
$source_kolory = DataObject::get('ModulKolory');
$kolory = $source_kolory->toDropDownMap('IkonaID','Nazwa');
return new FieldSet(
new DropdownField('KolorID','Wybierz kolor:',$kolory)
);
}
public function onAfterWrite() {
$filter = "IkonaID = $this->KolorID";
$kolor = DataObject::get_one('ModulKolory',$filter);
$filter = "ID = $this->KolorID";
$file = DataObject::get_one('File',$filter);
$filter = "ID = $this->ID";
$produkt_kolor = DataObject::get_one('ProduktKolory',$filter);
$produkt_kolor->Nazwa = $kolor->Nazwa;
$produkt_kolor->URL = $file->Filename;
$produkt_kolor->write();
return parent::onAfterWrite();
}
}
?>
but when i save new rocord the Apache server get lost