contao/core — Issue #3861: Sorting Mode 2 and pid in DCA with foreignKey
Author: tristanlins
Created: 2012-01-27 14:23:31+00:00
State: open

I have the following construct:
A parent table tl_parent and a child table tl_child. The child Table is in Mode 2, means it is accesable directly via the BE menu and does not have a pid parameter when viewed.
I added the tl_child.pid as a DCA field with foreignKey tl_parent.title, then the parent name is not shown in the grouping title. (Without the dca definition it works out of the box)
![missing grouping title](http://dl.dropbox.com/u/989588/mode2-2.png)

The problem is the DC_Table::formatCurrentValue method, the $value allready contains the title (not the id) of the tl_parent row. The select of the tl_parent row have everytime 0 rows and $remoteNew is uninitialised, so the method return NULL. I added $remoteNew = $value; as first line of formatCurrentValue to initialise the variable.

/**
* Return the formatted group header as string
* @param string
* @param mixed
* @param integer
* @return string
*/
protected function formatCurrentValue($field, $value, $mode)
{
$remoteNew = $value;
if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['multiple'])
{