7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » DataObjectManager many_many belongs_many relatation
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1432 Views |
-
DataObjectManager many_many belongs_many relatation

18 July 2010 at 1:53am Last edited: 18 July 2010 2:14am
I have two classes:
Many WarePages = many WareItems
and WareItem belongs many WarePagesWhen I edit WarePage I have to see all WareItems and if i need i have to add them in that dialog.
That one function displays all WareItems and places 'checked' only for items that belongs WarePage object and I can easily check or uncheck items, but I want to use DataObjectManager to display Items more correctly
$itemList = DataObject::get('WareItem');
$fields->addFieldToTab('Root.Content.WareItems', new CheckboxSetField('WareItems', '', $itemList));But DataObjectManager just displays all WareItems:
class WarePage extends Page {
static $many_many = array(
"WareItems" => "WareItem",
);
function getCMSFields() {
$fields = parent::getCMSFields();
$dataobjectmanager = new FileDataObjectManager(
$this,
'WareItems', // Source name
'WareItem', // Source class
'Photo', // File name on DataObject
array('Name' => 'Name','WareBrand.Name'=>'Brand','Article' => 'Article'),
'getCMSFields_forPopup'
);
$dataobjectmanager->setUploadFolder('WareHouse/'.$this->title);
$dataobjectmanager->enableUploadDebugging();
..
$fields->addFieldToTab("Root.Content.WarePageItems", $dataobjectmanager);return $fields;
}
}class WareItem extends DataObject {
...
static $belongs_many_many = array(
'WarePages' => 'WarePage'
);
..
} -
Re: DataObjectManager many_many belongs_many relatation

18 July 2010 at 3:21am
I'm not sure I understand. If the relationship is many_many, why are you using a regular DOM and not a ManyManyDOM?
-
Re: DataObjectManager many_many belongs_many relatation

18 July 2010 at 8:41am
There're no swf uploader, import images from directory and thumbnails for ManyManyDOM
I temporally made massive uploader for this one DOM, but maybe there're other way to do it.That's my code:
$dataobjectmanager = new ManyManyDataObjectManager(
$this, // Controller
'WareItems', // Source name
'WareItem', // Source class
array('Name' => 'Name','Article' => 'Article'),
'getCMSFields_forPopup'
);// SWF Upload
SWFUploadConfig::addPostParam('holderID', $this->ID);
SWFUploadConfig::addPostParam('holderClass', __CLASS__);
SWFUploadConfig::addPostParam('itemClass', 'WareItem');
$fields->addFieldToTab("Root.Content.MassiveUploader",
new SWFUploadField(
"EditForm",
"Upload",
"",
array(
'file_upload_limit' => 10,
'file_queue_limit' => 10,
'browse_button_text' => 'Add ware items ...',
'upload_url' => Director::absoluteURL('WarePage_Controller/uploadHandler'), // Custom Handler
'required' => 'true',
'debug' => 'true'
)
)
); -
Re: DataObjectManager many_many belongs_many relatation

18 July 2010 at 9:59am
I'm still confused. Why not ManyManyFileDataObjectManager?
-
Re: DataObjectManager many_many belongs_many relatation

18 July 2010 at 12:41pm Last edited: 18 July 2010 12:41pm
oh thx =) i'm sorry just didn't see it in manual =)
| 1432 Views | ||
|
Page:
1
|
Go to Top |

