I have a DO product:
class Product extends DataObject {
static $db = array(
'name' => 'Varchar',
'description' => 'HTMLText',
'price' => 'Decimal(6,2)',
);
static $has_many = array(
'Images' => 'MyImage'
);
public function getCMSFields_forPopup() {
$images = new MultipleImageUploadField('Images', 'Images');
$images->removeFolderSelection();
$images->uploadFolder = 'Uploads/Produktbilder';
return new FieldSet(
new TextField('name', 'Produktbezeichnung'),
new HtmlEditorField('description', 'Produktbeschreibung'),
new TextField('price', 'Preis'),
$images
);
}
}
and a MyImage:
class MyImage extends File {
static $has_one = array (
'Product' => 'Product'
);
}
I added Product to a tab with Dataobjectmanager:
$fields->addFieldToTab("Root.Content.Produkte", new DataObjectManager(
$this,
'Products',
'Product',
array(
'name' => 'Produktbezeichnung',
'description' => 'Produktbeschreibung',
'price' => 'Preis'
),
'getCMSFields_forPopup'
));
Now I can add Products, and also the Images to the products. But when I wan to edit the Product:
[Warning] array_flip() expects parameter 1 to be array, null given
GET /admin/EditForm/field/Products/item/3/edit?SecurityID=337b36073e9f80cfe044df4c334598fce74b2fad&ctf[Products][start]=0&ctf[Products][per_page]=10&ctf[Products][showall]=0&ctf[Products][sort]=&ctf[Products][sort_dir]=&ctf[Products][search]=&ctf[Products][filter]=
Line 1334 in /var/www/vhosts/xxx.at/httpdocs/sapphire/core/model/DataObject.php
1325
1326 if(!$remoteClass) {
1327 throw new Exception("Unknown $type component '$component' on class '$this->class'");
1328 }
1329
1330 if($fieldPos = strpos($remoteClass, '.')) {
1331 return substr($remoteClass, $fieldPos + 1) . 'ID';
1332 }
1333
1334 $remoteRelations = array_flip(Object::combined_static($remoteClass, 'has_one', 'DataObject'));
1335
1336 // look for remote has_one joins on this class or any parent classes
1337 foreach(array_reverse(ClassInfo::ancestry($this)) as $class) {
1338 if(array_key_exists($class, $remoteRelations)) return $remoteRelations[$class] . 'ID';
1339 }
1340
what could be wrong here?