0

I need the possibility to link images with audio files in the file management. I followed this tutorial and the field is created, but only as a simple input field. https://docs.contao.org/dev/reference/dca/fields/#meta-wizard-fields

Then i added a standard DCA setup

<?php
  $GLOBALS['TL_DCA']['tl_files']['fields']['meta']['eval']['metaFields']['audiolink'] = [
     'inputType' => 'fileTree',
     'eval' => ['filesOnly' => true, 'fieldType' => 'radio', 'mandatory' => false],
     'sql' => ['type' => 'string', 'length' => 255, 'default' => ''],
  ];

but this does not work.

With this i get the Page Tree Wizard

<?php
 $GLOBALS['TL_DCA']['tl_files']['fields']['meta']['eval']['metaFields']['audiolink'] = [
    'attributes' => 'maxlength="255"', 'dcaPicker' => true
 ];

Then i tried this

<?php
  $GLOBALS['TL_DCA']['tl_files']['fields']['meta']['eval']['metaFields']['audiolink'] = [
     'attributes' => 'maxlength="255"', 'fileTree' => true
  ];

but this does not work, too. So how to get the "fileTree" Wizard working at file management?

magic.77
  • 829
  • 1
  • 11
  • 21

1 Answers1

2

You can't, the meta wizard supports only text fields (and textarea fields since Contao 4.9.10).

Instead of using tl_files.meta, you could add an additional field to tl_files:

// contao/dca/tl_files.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;

$GLOBALS['TL_DCA']['tl_files']['fields']['foobar'] = [
    'inputType' => 'fileTree',
    'eval' => ['filesOnly' => true, 'fieldType' => 'radio', 'mandatory' => false],
    'sql' => "binary(16) NULL"
];

PaletteManipulator::create()
    ->addField('foobar', null)
    ->applyToPalette('default', 'tl_files')
;

However, this of course means that you can select this file only per file and not per language per file.

fritzmg
  • 2,494
  • 3
  • 21
  • 51