Hey Guys.
I need a little help:. I come so far (And i done it before but lost the code :( )
Here is my code:
class DocsLinks extends DataObject {
static $db = array(
'FirstName' => 'Text',
'Lastname' => 'Text',
'Nationality' => 'Text'
);
static $has_one = array(
'UnitSpec' => 'File'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'FirstName', 'First Name' ) );
$fields->push( new TextField( 'Lastname' ) );
$fields->push( new TextField( 'Nationality' ) );
$fields->push(new FileIFrameField( 'UnitSpec'));
return $fields;
}
}
AND IN THE PAGE:
static $db = array(
'LinksPageText' => 'text',
);
public static $has_one = array(
'MyStudent' => 'DocsLinks',
);
public static $has_many = array(
'UnitSpec' => 'File'
);
and...
$tablefield = new HasOneComplexTableField(
$this,
'MyStudent',
'DocsLinks',
array(
'FirstName' => 'First Name',
'Lastname' => 'Family Name',
'Nationality' => 'Nationality',
'UnitSpec' => 'UnitSpec'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab( 'Root.Content.Student', $tablefield );
I get this Error:
ERROR [User Error]: Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'File' IN POST /admin/EditForm/field/MyStudent Line 724 in /Users/stras/Documents/Projekte/okeanosRL/sapphire/core/Object.php Source ====== 715: 716: default : 717: throw new Exception ( 718: "Object->__call(): extra method $method is invalid on $this->class:" . var_export($config, true) 719: ); 720: } 721: } else { 722: // Please do not change the exception code number below. 723: * 724: throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175); 725: } 726: } 727: 728: // ----------------------------------------------------------------------------------------------------------------- 729: 730: /** Trace =====
Object->__call(forTemplate,Array) File->forTemplate() line 446 of ViewableData.php ViewableData->XML_val(UnitSpec) line 1252 of TableListField.php TableListField_Item->Fields() line 369 of ViewableData.php ViewableData->obj(Fields) line 512 of .cache.Users.stras.Documents.Projekte.okeanosRL.sapphire.templates.RelationComplexTableField.ss include(/private/var/tmp/silverstripe-cache-Users-stras-Documents-Projekte-okeanosRL/.cache.Users.stras.Documents.Projekte.okeanosRL.sapphire.templates.RelationComplexTableField.ss) line 392 of SSViewer.php SSViewer->process(HasOneComplexTableField) line 342 of ViewableData.php ViewableData->renderWith(RelationComplexTableField) line 275 of ComplexTableField.php ComplexTableField->FieldHolder() line 38 of HasManyComplexTableField.php HasManyComplexTableField->FieldHolder() line 275 of TableListField.php TableListField->index(SS_HTTPRequest) line 134 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 152 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 152 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 147 of Controller.php Controller->handleRequest(SS_HTTPRequest) line 283 of Director.php Director::handleRequest(SS_HTTPRequest,Session) line 127 of Director.php Director::direct(/admin/EditForm/field/MyStudent) line 127 of main.php
Plz help, i guess its a little error...