Defect #2247

DC_Table.php - Header Fields, references not working

Added by thyon 2 months ago. Updated about 1 month ago.

Status:Completed Start:
Priority:Normal Due date:
Assigned to:leo % Done:

0%

Category:backend
Target version:2.9.1

Description

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 <em>email</em>, <em>subject</em>, <em>message</em> and <em>cc</em> (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

related to Defect #1695: strlen() expects parameter 1 to be string in DC_Table Completed

History

Updated by leo 2 months ago

  • Status changed from New to Accepted
  • Assigned to set to leo
  • Target version set to 2.9.1

Updated by tsarma about 1 month ago

This isn't an issue, I have test by adding the line
$GLOBALS['TL_DCA']['tl_form_field']['list']['sorting']['headerFields'][] = 'format';
in dcaconfig.php and changing forms Data format to csv, xml... It's showing up in child tables header field.

Is this something to do with PHP version? Mine is PHP Version 5.2.6-1+lenny8. Just curious to know.

Updated by leo about 1 month ago

  • Status changed from Accepted to Completed

Also available in: Atom