From 1e40d07a98e04c2eb8b39a318420cca763b823e0 Mon Sep 17 00:00:00 2001 From: Jackson Date: Fri, 6 Apr 2018 14:18:14 +1200 Subject: [PATCH] Set "title field" at a meaningful point in TagField instantiation * Switch diet to dogfood --- src/TagField.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/TagField.php b/src/TagField.php index 45cf81e..409a9d9 100644 --- a/src/TagField.php +++ b/src/TagField.php @@ -65,6 +65,7 @@ class TagField extends DropdownField * @param string $title * @param null|DataList $source * @param null|DataList $value + * @param string $titleField */ public function __construct($name, $title = '', $source = [], $value = null, $titleField = 'Title') { @@ -255,10 +256,10 @@ class TagField extends DropdownField } if (is_array($values)) { - $values = DataList::create($dataClass)->filter($this->titleField, $values); + $values = DataList::create($dataClass)->filter($this->getTitleField(), $values); } - $ids = $values->column($this->titleField); + $ids = $values->column($this->getTitleField()); $titleField = $this->getTitleField(); @@ -284,10 +285,10 @@ class TagField extends DropdownField $name = $this->getName(); if ($source->hasMethod($name)) { - $value = $source->$name()->column($this->titleField); + $value = $source->$name()->column($this->getTitleField()); } } elseif ($value instanceof SS_List) { - $value = $value->column($this->titleField); + $value = $value->column($this->getTitleField()); } if (!is_array($value)) {