From 96dc68433be88f2a47c699149e2dd857159facfd Mon Sep 17 00:00:00 2001 From: PingusPepan Date: Sun, 4 Dec 2016 09:11:01 +0100 Subject: [PATCH] Basic support for related column names (#413) Added basic support for syntax $grid->addColumnType('name', 'Title', ':related_table.column') --- src/Row.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Row.php b/src/Row.php index c3a615a8..0e33ef13 100644 --- a/src/Row.php +++ b/src/Row.php @@ -92,6 +92,12 @@ public function getValue($key) return $this->item->{$this->formatDibiRowKey($key)}; } else if ($this->item instanceof ActiveRow) { + if (preg_match("/^:([a-zA-Z0-9_$]*)\.([a-zA-Z0-9_$]*)$/", $key, $matches)) { + $relatedTable = $matches[1]; + $relatedColumn = $matches[2]; + + return $this->item->related($relatedTable)->fetch()->{$relatedColumn}; + } return $this->item->{$key}; } else if ($this->item instanceof Nette\Database\Row) {