Set "title field" at a meaningful point in TagField instantiation

* Switch diet to dogfood
This commit is contained in:
Jackson 2018-04-06 14:18:14 +12:00
parent 7a286d432d
commit 1e40d07a98

View File

@ -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)) {