Mate I am probably boring my now, but I don't see the problem, can you fix this for me?
This is my actual code
<?php
class Challenge extends DataObject{
static $db=array(
'Naziv' => 'Text',
'Datum' => 'Date',
'Opis'=>'Text',
'Aktivan'=>'Boolean'
);
static $has_one=array(
'Izazov'=>'File',
'Razultati'=>'File',
'Izazovi' => 'Izazovi',
'IzazoviArhiva' => 'IzazoviArhiva'
);
public function getCMSFields_forPopup(){
return new FieldSet(
new TextField('Naziv','Naziv izazova'),
new DatePickerField('Datum'),
new TextField('Opis','Krataki opis'),
new FileIFrameField('Izazov'),
new FileIFrameField('Rezultati'),
new CheckboxField('Aktivan')
);
}
}
?>
<?php
/**
* Izazovi page type - sadrzi aktivne izazove
*/
class Izazovi extends Page {
static $has_one = array(
'Photo' => 'Image'
);
static $allowed_children = array(
'IzazoviArhiva',
'Challenge'
);
static $has_many=array(
'Challenges'=>'Challenge'
);
static $db = array(
'Content' => 'Text'
);
public function getCMSFields(){
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'Challenges', // Source name
'Challenge', // Source class
'Izazov', // File name on DataObject
'Rezultati', // File name on DataObject
array(
'Naziv' => 'Naziv',
'Datum' => 'Datum',
'Opis' => 'Opis',
'Aktivan'=> 'Aktivan'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$fields->removeFieldFromTab('Root.Content.Main', 'Content');
$fields->addFieldToTab("Root.Content.Image", new ImageField('Photo','Slika'));
$fields->addFieldToTab('Root.Content.Main', new TextareaField('Content', 'Content', 20));
$fields->addFieldToTab("Root.Content.Izazovi",$manager);
return $fields;
}
}
class Izazovi_Controller extends Page_Controller {
...
and the error it gives me in /admin/ :
ERROR [Warning]: Invalid argument supplied for foreach()
IN POST /ss/admin/getitem?ID=19&ajax=1
Line 284 in /var/www/ss/dataobject_manager/code/DataObjectManager.php
Source
======
275: if(!$this->controller->ID && $this->isNested)
276: return $this->renderWith('DataObjectManager_holder');
277: return parent::FieldHolder();
278: }
279:
280:
281: public function Headings()
282: {
283: $headings = array();
* 284: foreach($this->fieldList as $fieldName => $fieldTitle) {
285: if(isset($_REQUEST['ctf'][$this->Name()]['sort_dir']))
286: $dir = $_REQUEST['ctf'][$this->Name()]['sort_dir'] == "ASC" ? "DESC" : "ASC";
287: else
288: $dir = "ASC";
289: $headings[] = new ArrayData(array(
290: "Name" => $fieldName,
Trace
=====
<ul>DataObjectManager->Headings()
line 369 of ViewableData.php
ViewableData->obj(Headings,,1)
line 245 of .cache.dataobject_manager.templates.DataObjectManager.ss
include(/tmp/silverstripe-cache-var-www-ss/.cache.dataobject_manager.templates.DataObjectManager.ss)
line 420 of SSViewer.php
SSViewer->process(DataObjectManager)
line 342 of ViewableData.php
ViewableData->renderWith(DataObjectManager)
line 275 of ComplexTableField.php
ComplexTableField->FieldHolder()
line 277 of DataObjectManager.php
DataObjectManager->FieldHolder()
line 369 of ViewableData.php
ViewableData->obj(FieldHolder,,,1)
line 446 of ViewableData.php
ViewableData->XML_val(FieldHolder,,1)
line 73 of .cache.sapphire.templates.TabSetFieldHolder.ss
include(/tmp/silverstripe-cache-var-www-ss/.cache.sapphire.templates.TabSetFieldHolder.ss)
line 420 of SSViewer.php
SSViewer->process(TabSet)
line 342 of ViewableData.php
ViewableData->renderWith(TabSetFieldHolder)
line 80 of TabSet.php
TabSet->FieldHolder()
line 369 of ViewableData.php
ViewableData->obj(FieldHolder,,,1)
line 446 of ViewableData.php
ViewableData->XML_val(FieldHolder,,1)
line 58 of .cache.sapphire.templates.TabSetFieldHolder.ss
include(/tmp/silverstripe-cache-var-www-ss/.cache.sapphire.templates.TabSetFieldHolder.ss)
line 420 of SSViewer.php
SSViewer->process(TabSet)
line 342 of ViewableData.php
ViewableData->renderWith(TabSetFieldHolder)
line 80 of TabSet.php
TabSet->FieldHolder()
line 369 of ViewableData.php
ViewableData->obj(FieldHolder,,,1)
line 446 of ViewableData.php
ViewableData->XML_val(FieldHolder,,1)
line 77 of .cache.sapphire.templates.Includes.Form.ss
include(/tmp/silverstripe-cache-var-www-ss/.cache.sapphire.templates.Includes.Form.ss)
line 420 of SSViewer.php
SSViewer->process(Form)
line 342 of ViewableData.php
ViewableData->renderWith(Array)
line 1108 of Form.php
Form->forTemplate()
line 1135 of Form.php
Form->formHtmlContent()
line 391 of LeftAndMain.php
LeftAndMain->getitem(SS_HTTPRequest)
line 193 of Controller.php
Controller->handleAction(SS_HTTPRequest)
line 143 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
line 147 of Controller.php
Controller->handleRequest(SS_HTTPRequest)
line 282 of Director.php
Director::handleRequest(SS_HTTPRequest,Session)
line 125 of Director.php
Director::direct(/admin/getitem)
line 127 of main.php
</ul>