Hey guys,
I´ve working with many_many_extraFields to generate TextFields in related DataObjects.
But after setting the extraFields, I can´t call the variables in the related object (like: $this->ID, $this->Title).
MyParent.php
class MyParent extends DataObject{
private static $db = array(
"Title" => "Varchar(255)"
);
static $many_many = array(
'MyChildren' => 'MyChild'
);
public static $many_many_extraFields = array(
'MyChildren' => array('Foo' => 'Varchar(255)')
);
public function getCMSFields(){
$fields = parent::getCMSFields();
$config = GridFieldConfig_RecordEditor::create();
$childrenFields = singleton('MyChild')->getCMSFields();
$childrenFields->addFieldToTab('Root.Main', TextField::create('ManyMany[Foo]', 'Foo'));
$config->getComponentByType('GridFieldDetailForm')->setFields($childrenFields);
$gridfield = new GridField("MyChildren", "MyChild", $this->MyChildren(), $config);
$fields->addFieldToTab("Root.Main", $gridfield);
return $fields;
}
}
MyChild.php
class MyChild extends DataObject{
private static $db = array(
"Title" => "Varchar(255)"
);
private static $belongs_many_many = array(
"MyParents" => "MyParent"
);
public function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Main", new LiteralField("Foo", $this->ID));
return $fields;
}
}
Has anyone a solution or a workaround?