Didnt work i write u may code maybe u can tell whats wrong!
Mootorrattas.php
<?php
class Mootorrattas extends DataObject
{
static $db = array (
'MootorrattaCategory' => "Enum('Enduro,Sport,Tour,Racing')",
'Mootorrattanimi' => 'Text',
'Kirjeldus' => 'HTMLText',
'Mootor' => 'Text',
'Mootorivoimsus' => 'Text',
'Poordemoment' => 'Text',
'Surveaste' => 'Text',
'Kytusesisselase' => 'Text',
'Tippkiirus' => 'Text',
'Sidur' => 'Text',
'Kaivitussysteem' => 'Text',
'Kaigukast' => 'Text',
'Amordid' => 'Text',
'Pidurid' => 'Text',
'Rattad' => 'Text',
'Istmekorgus' => 'Text',
'Bensiinipaak' => 'Text',
'Tyhimass' => 'Text',
'Varvid' => 'Text',
'Garantii' => 'Text',
'Muuinfo' => 'Text',
'Hind' => 'Text',
'Soodushind' => 'Text',
'Tahelepanu' => 'HTMLText',
);
static $has_one = array (
'Mootorrattalist' => 'Mootorrattalist',
'Photo' => 'Image'
);
static $has_many = array (
'MootorrattasGalleryImages' => 'MootorrattasGalleryImage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new DropdownField('MootorrattaCategory','MootorrattaCategory',singleton('Mootorrattas')->dbObject('MootorrattaCategory')->enumValues()),
new TextField('Mootorrattanimi', 'Mootorratta nimi'),
new SimpleWysiwygField('Kirjeldus', 'Mootorratta kirjeldus'),
new TextField('Mootor', 'Mootor'),
new TextField('Mootorivoimsus', 'Mootori võimsus'),
new TextField('Poordemoment', 'Pöördemoment'),
new TextField('Surveaste', 'Surveaste'),
new TextField('Kytusesisselase', 'Kütuse sisselase'),
new TextField('Tippkiirus', 'Tippkiirus'),
new TextField('Kaivitussysteem', 'Käivitussüsteem'),
new TextField('Sidur', 'Sidur'),
new TextField('Kaigukast', 'Käigukast'),
new TextField('Amordid', 'Amordid'),
new TextField('Pidurid', 'Pidurid'),
new TextField('Rattad', 'Rattad'),
new TextField('Istmekorgus', 'Istmekõrgus'),
new TextField('Bensiinipaak', 'Bensiinipaak'),
new TextField('Tyhimass', 'Tühimass'),
new TextField('Varvid', 'Värvid'),
new TextField('Garantii', 'Garantii'),
new TextField('Muuinfo', 'Muu info'),
new TextField('Hind', 'Hind'),
new TextField('Soodushind', 'Soodushind'),
new SimpleWysiwygField('Tahelepanu', 'Tähelepaneku tekst'),
new ImageField('Photo', 'Mootorratta pilt'),
new ImageDataObjectManager(
$this,
'MootorrattasGalleryImages', // Source name
'MootorrattasGalleryImage', // Source class
'MootorrattasMyGalleryImage', // File name on DataObject
array('MootorrattasGalleryImageTitle' => 'MootorrattasGalleryImageTitle')
)
);
}
function Link(){
return $this->Mootorrattalist()->Link() .'show/'.$this->ID;
}
public function SuurHind() {
return $this->Hind > 50000;
}
}
?>
this is the dataobject
Pagetype is Mootorrattalist.php:
<?php
class Mootorrattalist extends Page
{
static $has_many = array (
'Mootorrattad' => 'Mootorrattas'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$f->removeFieldFromTab("Root.Content.Main","Content");
$manager = new DataObjectManager(
$this, // Controller
'Mootorrattad',
'Mootorrattas',
array(
'Mootorrattanimi' => 'Mootorrattanimi'
),'getCMSFields_forPopup'
);
$f->addFieldToTab('Root.Content.Main', $manager);
return $f;
}
}
class Mootorrattalist_Controller extends Page_Controller
{
function show(){
return array();
}
function Mootorrattas(){
if(isset($this->request) && $this->request->param('ID')){
return DataObject::get_by_id('Mootorrattas', (int)$this->request->param('ID'));
}
}
public function Categories() {
$ret = new DataObjectSet();
foreach(singleton('Mootorrattas')->dbObject('MootorrattaCategory')->enumValues() as $cat) {
$ret->push(new ArrayData(array( 'CategoryName' => $cat, 'bikes' => DataObject::get("Mootorrattas","MootorrattaCategory = '$cat'")
)));
}
}
}
?>
and the .ss file:
<% control Categories %>
$CategoryName
<% control bikes %>
$MootorrattasField1 $MootorrattasField2
<% end_control %>
<% end_control %>