Last active
August 16, 2016 03:11
-
-
Save muskie9/ada308ae7551d9ad6520d22fb684a3d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$relations = $this->stat('has_many'); | |
$dropdowns = []; | |
foreach($relations as $name => $obj){ | |
$field = Dropdown::create($name) | |
->setTitle(Config::inst()->get($obj, 'singular_name')) | |
->setEmptyString('Select one') | |
->setSource($this->$name()->map('Title', 'Title')); | |
array_push($dropdowns, $field); | |
} | |
$fields->addFieldsToTab('Root.Dropdowns', $dropdowns); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment