Skip to content

Instantly share code, notes, and snippets.

@kinglozzer
Created June 6, 2014 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinglozzer/3844f78dbdb99fe41972 to your computer and use it in GitHub Desktop.
Save kinglozzer/3844f78dbdb99fe41972 to your computer and use it in GitHub Desktop.
<?php
class MyDataObject extends DataObject {
public function getCMSFields() {
$fields = parent::getCMSFIelds();
$clientSource = function() {
return Client::get()->map('ID', 'ClientName');
};
$clientIDField = new DropdownField('ClientID', 'Client', $clientSource());
$clientIDField->useAddNew('Client', $clientSource);
$fields->addFieldToTab('Root.Foo', $clientIDField);
return $fields;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment