Pinter Krisztian
Pinter Krisztian

Reputation: 18

How to extend TYPO3 TCEforms image with a new field (column)?

I'm using TYPO3 12.4.6

I want to add an extra Subtitle attribute (input field) beside the existing Title to the Image element and I want to store it into the sys_file_reference table.

The following image contains the Image element, which should be extended with the new attribute:

Existing Image form element

I've already tried to to do it using ExtensionManagementUtility::addTCAcolumns, and ExtensionManagementUtility::addToAllTCAtypes , but it isn't working. The full code I wrote:

<?php

defined('TYPO3') or die();

$fields = [
    'subtitle' => [
        'label' => 'Subtitle',
        'config' => [
            'type' => 'input',
            'eval' => 'trim'
        ]
    ]
];


\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_reference', $fields);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
    'sys_file_reference',
    'subtitle',
    '',
    'before:crop'
);

So, to repeat the question: How can I add new input filed/attribute to the existing Image element?

Upvotes: 0

Views: 261

Answers (2)

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10791

As the crop field is not listed in showitem of any type your insertion with before:crop is not specific.

You can find the crop field listed in the palette imageoverlayPalette. Though you should add your field to that palette:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
   'sys_file_reference',
   'imageoverlayPalette',
   'subtitle',
   'after:title'
);

(after:title as there is a --linebreak-- between the fields title and crop and your field belongs more to the text-fields than to the button)

Upvotes: 0

Milenov
Milenov

Reputation: 1

Where have you defined the property for that field? I'm pretty sure you need one and of course a partial for that property to be able to render it. Can

Upvotes: -1

Related Questions