Project

General

Profile

Actions

Bug #103532

open

Using TSconfig TCEFORM to change existing flexform field configuration does not work

Added by Garvin Hicking 8 months ago. Updated 2 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Start date:
2024-04-04
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
tsconfig tceform flexform
Complexity:
easy
Is Regression:
No
Sprint Focus:

Description

You can use TSconfig TCEFORM to change attributes of flexform fields via:

TCEFORM.tx_styleguide_flex.flex_file_1.default.sDEF.input_1.label = Override Label

However, you can not change the "config" section of a field, for example to add a enableRichtext attribute, or change the rows/cols of an input. This is currently only possible to change for main-level fields like "tt_content.header", but not for flexform fields:

TCEFORM.tx_styleguide_flex.flex_file_1.default.sDEF.input_1.config.max = 30
TCEFORM.tx_styleguide_flex.flex_file_1.default.sDEF.input_1.config.size = 5

You can already use PSR-14 events (AfterFlexFormDataStructureParsedEvent) to modify a flexform, but this is a bit more complicated than just using TSconfig. So I'd argue that setting it via TSconfig should be possible.


Related issues 3 (2 open1 closed)

Related to TYPO3 Core - Bug #102595: Not possible to override richtextConfiguration via TSconfig if in a flexformAccepted2023-12-04

Actions
Related to TYPO3 Core - Feature #36609: Overwriting flexform in page TSConfig is not respected in TCEMainAccepted2012-04-26

Actions
Related to TYPO3 Core - Feature #91690: Override Flexform via Page TsConfigClosed2020-06-22

Actions
Actions #1

Updated by Garvin Hicking 8 months ago

  • Related to Bug #102595: Not possible to override richtextConfiguration via TSconfig if in a flexform added
Actions #2

Updated by Garvin Hicking 8 months ago

  • Related to Feature #36609: Overwriting flexform in page TSConfig is not respected in TCEMain added
Actions #3

Updated by Garvin Hicking 8 months ago

  • Related to Feature #91690: Override Flexform via Page TsConfig added
Actions #4

Updated by Gerrit Code Review 8 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #5

Updated by Gerrit Code Review 8 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #6

Updated by Garvin Hicking 8 months ago ยท Edited

For reference, here's how you could already achieve this with the AfterFlexFormDataStructureParsedEvent:

In a custom extension (i.e. sitepackage, with a vendor like "MyVendor") do this:

1. Add to sitepackage/Configuration/Services.yaml:

services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false

        MyVendor\Sitepackage\:
            resource: '../Classes/*'

        MyVendor\Sitepackage\Backend\FlexFormParsingModifyEventListener:
            tags:
                - name: event.listener
                  identifier: 'sitepackage/modify-data-structure'
                  method: 'modifyDataStructure'

2. Create sitepackage/Classes/Backend/FlexFormParsingModifyEventListener.php:

<?php
declare(strict_types=1);

namespace MyVendor\Sitepackage\Backend;

use TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent;

final class FlexFormParsingModifyEventListener
{
    public function modifyDataStructure(AfterFlexFormDataStructureParsedEvent $event): void
    {
        $identifier = $event->getIdentifier();
        if (
            (($identifier['fieldName'] ?? '') === 'flex_file_1') &&
            (($identifier['tableName'] ?? '') === 'tx_styleguide_flex') &&
            (($identifier['dataStructureKey'] ?? '') === 'default')
        ) {
            $parsedDataStructure = $event->getDataStructure();
            if (isset($parsedDataStructure['sheets']['sDEF']['ROOT']['el']['input_1']['config'])) {
                $parsedDataStructure['sheets']['sDEF']['ROOT']['el']['input_1']['config']['max'] = 30;
                $parsedDataStructure['sheets']['sDEF']['ROOT']['el']['input_1']['config']['size'] = 5;
            }
            $event->setDataStructure($parsedDataStructure);
        }
    }
}

3. Reset your cache, go to the backend, and it should now populate input_1 with the extra attributes.

Note that this PSR-14 event is much more flexibel because the Matrix is not enforced here, and thus you can perform any change you see fit (also changing input types). However, the TCEFORM TSconfig way is less hassle to implement.

Actions #7

Updated by Gerrit Code Review 8 months ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #8

Updated by Gerrit Code Review 8 months ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #9

Updated by Gerrit Code Review 8 months ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #10

Updated by Gerrit Code Review 8 months ago

Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #11

Updated by Gerrit Code Review 8 months ago

Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #12

Updated by Gerrit Code Review 8 months ago

Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #13

Updated by Gerrit Code Review 8 months ago

Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions #14

Updated by Gerrit Code Review 2 months ago

Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/83646

Actions

Also available in: Atom PDF