Silverstripe 3.0 Has One Relationship to DropdownField
With Silverstripe’s new ORM some of the function calls to get data for a drop-down field have changed slightly. Here’s the new way to populate a DropdownField with the available options for a HasOne relationship:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
... static $has_one = array( 'Project' => 'Project' ); function getCMSFields() { ... // If your name field is stored in the Title column $dropDownField = new DropdownField( 'ProjectID', 'Project', Project::get()->map() ); // Or if your object doesn't have a 'Title' field $dropDownField = new DropdownField( 'ProjectID', 'Project', Project::get()->map('IDColumn', 'NameColumn') ); ... } ... |