contao/test — Issue #2247: DC_Table.php - Header Fields, references not working
Author: importer
Created: 2011-11-29 09:21:09+00:00
State: open
Labels: backend, Defect

How to generate this bug:

The format field in tl_form.php is defined as SELECT, using a language reference and helpwizard=>true as follows

```
'format' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_form']['format'],
'default' => 'raw',
'exclude' => true,
'inputType' => 'select',
'options' => array('raw', 'xml', 'csv', 'email'),
'reference' => &$GLOBALS['TL_LANG']['tl_form'],
'eval' => array('helpwizard'=>true, 'tl_class'=>'w50')
),
```

The corresponding language reference is an array (to generate the HELP text in the Helpwizard pop-up).

```
$GLOBALS['TL_LANG']['tl_form']['raw'] = array('Raw data', 'The form data will be sent as plain text message with each field in a new line.');
$GLOBALS['TL_LANG']['tl_form']['xml'] = array('XML file', 'The form data will be attached to the e-mail as an XML file.');
$GLOBALS['TL_LANG']['tl_form']['csv'] = array('CSV file', 'The form data will be attached to the e-mail as a CSV file.');
$GLOBALS['TL_LANG']['tl_form']['email'] = array('E-mail', 'Ignores all fields except email, subject, message and cc (carbon copy) and sends the form data like it had been sent from a mail client. File uploads are allowed.');
```

This all works, EXCEPT, when you add this field to the Child Table, tl_form_field.php in the HEADER section of the child DCA.

```
$GLOBALS['TL_DCA']['tl_form_field']['list']['sorting']['headerFields'][] = 'format';
```

This is the error it generates, because you didn't take into account in the parent-child view, that the header view will need to take awareness of the array() in the language file, instead of just checking for strlen() -- if it's a string.

```
Warning: strlen() expects parameter 1 to be string, array given in /Library/WebServer/Documents/demo/system/drivers/DC_Table.php on line 3295
#0 [internal function]: __error(2, 'strlen() expect...', '/Library/WebSer...', 3295, Array)
#1 /Library/WebServer/Documents/demo/system/drivers/DC_Table.php(3295): strlen(Array)
#2 /Library/WebServer/Documents/demo/system/drivers/DC_Table.php(345): DC_Table->parentView()
#3 /Library/WebServer/Documents/demo/system/modules/backend/Backend.php(234): DC_Table->showAll()
#4 /Library/WebServer/Documents/demo/contao/main.php(101): Backend->getBackendModule('form')
#5 /Library/WebServer/Documents/demo/contao/main.php(297): Main->run()
#6 {main}
```

Related issues: #1695

--- _Originally created by thyon on July 4th, 2010, at 11:55pm (ID 2247)_