Thanks kinglozzer. It works nice on regular fields.
Any idea how this would work on many_many_extrafields?
class ProductPage extends DataObject{
static $many_many = array(
'Products' => 'Product'
);
public static $many_many_extraFields = array(
'Products' => array('Position' => 'Varchar(255)')
);
public function getCMSFields(){
$fields = parent::getCMSFields();
$productFields = singleton('Product')->getCMSFields();
$productFields->addFieldToTab('Root.Main', DropdownField::create('ManyMany[Position]', 'Position on page', array("top", "bottom")));
$gridfieldConfig = GridFieldConfig_RelationEditor::create();
$gridfieldConfig->getComponentByType('GridFieldDetailForm')->setFields($productFields);
$fields->addFieldsToTab("Root.Main", array(
...
$gridfield = GridField::create("Products", "Product", $this->Products(), $gridfieldConfig)
));
}
class Product extends DataObject{
...
$fields->fieldByName("Root.Main")->push($OptionSetField);
$fields->fieldByName("Root.Main")->push($uploadField);
$fields->fieldByName("Root.Main")->push(ManyMany[Position]);
$fields->fieldByName("Root.Main")->push($Title);
}
I have the bad feeling, that this doesn´t work anyway, does it?