Gernott / mask

TYPO3 Extension Mask
https://www.facebook.com/typo3mask
GNU General Public License v2.0
130 stars 86 forks source link

Default values being set on all following tt_content entries #553

Closed justlunix closed 1 year ago

justlunix commented 1 year ago

Using mask v7.2.16 on typo 3 11.5.24. Also tested with mask 8.1

When setting a default value for a mask element, the content of that field is being set to all following tt_content entries, no matter the ctype. It should only set the default value if it actually is that mask element.

Database: image

You can see that after the mask element has been created, the value is being added to all elements after that. This scales up extremely depending on the amount of default values and tt_content entries.

nhovratov commented 1 year ago

This is not a bug. It has always been like this in TYPO3. You can change the CType of a content element and so then the default value should be loaded.

The only way to circumvent this, is to use columnsOverrides so that the default value is only applied per CType. Mask is not capable of doing this right now, but you can do this with TCA overrides.

justlunix commented 1 year ago

IMO, this trade-off makes the default value being unusable. There is just way too much data in the db in the long run and using this field for a search index isn't working either anymore then. I have never used tca overrides before, do you have an example of how to achieve this?

nhovratov commented 1 year ago

I think the default value is rarely used for Text fields, but rather for default options with numerical values.

Here is how to use them in general: https://docs.typo3.org/p/mask/mask/main/en-us/Guides/OverrideTCA.html

In your case you want to use columnsOverrides: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Types/Properties/ColumnsOverrides.html

For example: $GLOBALS['TCA']['tt_content']['types']['mask_element1']['columnsOverrides']['text_field1']['config']['default'] = 'My default value, which is only applied for CType mask_element1'.

nhovratov commented 1 year ago

As this is TYPO3 Core behaviour and probably intended, I'll close this issue here.