Skip to content

Commit

Permalink
Basic support for related column names (#413)
Browse files Browse the repository at this point in the history
Added basic support for syntax $grid->addColumnType('name', 'Title', ':related_table.column')
  • Loading branch information
PingusPepan authored and paveljanda committed Dec 4, 2016
1 parent fe15524 commit 96dc684
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 96dc684

Please sign in to comment.