Hi guys,
I have Category DataObject with $many_many products and a Product DataObject with $belongs_many_many Category. I want display categories on CMS admin on different group to make interface be more usable. But I only can put one field for each Product...
I want display...
Product.php
//Relations...
static $belongs_many_many = array(
'Categories' => 'PCCategory'
);
//On getCMS()
new CheckboxSetField('Category', 'Root categories', $this->getRootCategories()),
new CheckboxSetField('Category', 'Level 2 categories', $this->getLevel2Categories()) //Wrong because i used 'Categorý' on previous line, How i can do this on correct way?
//Functions...
function getRootCategories()
{
$map = array();
foreach (PCCategory::get() as $category) {
if($category->RootCategory) {
$map[$category->ID] = $category->Title;
}
}
return $map;
}
function getLevel2Categories(){
$map = array();
foreach (PCCategory::get() as $category) {
foreach($category->ParentCategories() as $parentCategory){
if($parentCategory->RootCategory){
$map[$category->ID] = $category->Title;
}
}
}
return $map;
}
Category.php
//Relations
private static $many_many = array(
'ChildCategories' => 'Category',
'Products' => 'PCProduct'
);
private static $belongs_many_many = array(
'ParentCategories' => 'Category'
);
How i can display custom field?