-
Notifications
You must be signed in to change notification settings - Fork 35
Description
I needed to use a FilteredDropdownSet, but the label in the dependent dropdown box came from a method (e.g., getFullName()) instead of a single database field. This required a small modification to the FilteredDropdownSet. I think that this might be useful for others too.
The change is too small for me to bother forking the project and sending a pull request, so here's the patch:
code/dropdown_fields/FilteredDropdownSet.php | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/code/dropdown_fields/FilteredDropdownSet.php b/code/dropdown_fields/FilteredDropdownSet.php
index 09da7dd..64267e6 100755
--- a/code/dropdown_fields/FilteredDropdownSet.php
+++ b/code/dropdown_fields/FilteredDropdownSet.php
@@ -52,7 +52,9 @@ class FilteredDropdownSet extends FieldGroup {
$results = DataObject::get($this->sourceClass, $filter);
if($results) {
foreach($results as $r) {
-
$ret[$r->{$this->returnKey}] = $r->{$this->returnLabel}; -
$ret[$r->{$this->returnKey}] = -
($r->hasMethod($this->returnLabel) ? -
--
$r->{$this->returnLabel}(): $r->{$this->returnLabel}); } } return Convert::array2json($ret);
1.7.7.GIT