84526[FEATURE] Make scale of TCA type number configurable
Commit message
Review
-
Code review CR +2 Done
- Garvin Hicking +2
- Benni Mack +1
-
Verified V +2 Done
- Garvin Hicking +2
- Benni Mack +1
- core-ci +1 CI
Issues 1
Files 29
- Build/Sources/TypeScript/backend/form-engine/field-wizard/value-slider.ts2+3 −2
- Build/Sources/TypeScript/backend/tests/form-engine-validation-test.ts+27 −0
- Build/Sources/TypeScript/backend/form-engine-validation.ts+23 −10
- typo3/sysext/backend/Classes/Form/Element/NumberElement.php2+33 −15
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine/field-wizard/value-slider.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/form-engine-validation.js+1 −1
- typo3/sysext/backend/Tests/Unit/Form/Element/NumberElementTest.phpnew+150 −0
- typo3/sysext/core/Classes/Configuration/Tca/TcaMigration.php+51 −0
- typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php4+9 −6
- typo3/sysext/core/Classes/DataHandling/DataHandler.php+16 −18
- typo3/sysext/core/Classes/Schema/Field/NumberFieldType.php4+31 −2
- typo3/sysext/core/Classes/Utility/MathUtility.php+86 −0
- typo3/sysext/core/Documentation/Changelog/15.0/Deprecation-102217-DeprecateNumberFieldType-getFormat.rstnew+43 −0
- typo3/sysext/core/Documentation/Changelog/15.0/Feature-102217-ConfigurableScaleForTCATypeNumber.rstnew+123 −0
- typo3/sysext/core/Tests/Functional/DataHandling/Regular/CheckValueTest.php+31 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler/Configuration/TCA/Overrides/tt_content.php+26 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_csv/Configuration/TCA/tx_testirrecsv_price.php+1 −1
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield/Configuration/TCA/tx_testirreforeignfield_price.php+1 −1
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_mm/Configuration/TCA/tx_testirremm_price.php+1 −1
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_mnattributeinline/Configuration/TCA/tx_testirremnattributeinline_price.php+1 −1
Show 9 more files
- typo3/sysext/core/Tests/Functional/Schema/SearchableSchemaFieldsCollectorTest.php+3 −3
- typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaMigrationTest.php+145 −2
- typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaTest.php+80 −3
- typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php+171 −3
- typo3/sysext/core/Tests/Unit/Utility/MathUtilityTest.php+80 −0
- typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/test_data_mapper/Configuration/TCA/tx_testdatamapper_domain_model_constructor_promotion_example.php+1 −1
- typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/test_data_mapper/Configuration/TCA/tx_testdatamapper_domain_model_example.php+1 −1
- typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGenerator/TypeNumberFormatDecimal.php+1 −1
- typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php1+65 −5
Review log 2637
Show 812 earlier messages
-
Georg Ringer uploaded patch set 1 06/07/24, 15:15
-
Georg Ringer uploaded patch set 2 06/07/24, 15:16
-
core-ci voted on patch set 1 V -1 06/07/24, 15:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58880
-
core-ci voted on patch set 2 V -1 06/07/24, 15:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58881
-
Ayke Halder commented on patch set 2 06/07/24, 19:51
Is this one here also related? https://github.com/TYPO3/typo3/blob/d3008fcd3eb3c3049049a2dbaf759b7418e95805/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L1645-L1647 ```php /** * Evaluate 'number' type values * * @param mixed $value The value to set. * @param array $tcaFieldConf Field configuration from TCA */ protected function checkValueForNumber(mixed $value, array $tcaFieldConf): array { […] if ($format === 'decimal') { // @todo Make precision configurable $precision = 2; ```NumberElement.php:224`'0.' . str_repeat('0', $scale - 1) . '1'` could be replaced with `'0.' . sprintf("%'0${scale}d", 1);` or `sprintf("0.%'0${scale}d", 1);`DefaultTcaSchema.php:1024Maybe replace `0.00` with `0.0` as both are a float with value `0.0`.tx_styleguide_elements_basic.php:1901Maybe add one blank or remove them all. -
Garvin Hicking commented on patch set 2 02/19/26, 08:34
Would you like to pick this up? I was just annoyed we have this hardcoded :D :D -
Josef Glatz commented on patch set 2 04/07/26, 08:53
that would be a nice gem for any upcoming TYPO3 version 😊 -
Georg Ringer uploaded patch set 3
V -108/27/26, 19:00 -
Georg Ringer commented on patch set 3 08/27/26, 19:06
This change is ready for review. -
core-ci voted on patch set 3 V -1 08/27/26, 20:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107289
-
core-ci commented on patch set 3 08/27/26, 20:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107289
-
Georg Ringer uploaded patch set 4
V -109/01/26, 14:37
-
core-ci voted on patch set 3 V -1 09/01/26, 14:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107289
-
core-ci voted on patch set 4 V -1 09/01/26, 15:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107499
-
Georg Ringer uploaded patch set 5
V -109/01/26, 20:35 -
core-ci voted on patch set 5 V +1 09/01/26, 20:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107525
-
Garvin Hicking commented on patch set 5 V +1 09/02/26, 09:29
Reply
DoneSeems to work well for me. I'm not deep into the decimal / scientific notation parsing algorithms but the code reads sane to me.value-slider.ts:75I think we should also allow "precision" as a fallback to prevent a BC of this componentNumberElement.php:224ReplyDoneDefaultTcaSchema.php:1024ReplyDone -
Daniel Windloff commented on patch set 5 09/11/26, 07:51
Hey, very nice feature. just two remarks: - I think the coupling between TcaSchmea and other parts of the core is not beneficial. - I suggest using this feature for the columns `latitude` and `longitude` in `EXT:filemetadata/Configuration/TCA/Overrides/sys_file_metadata.php`NumberFieldType.php:59I would suggest avoiding static methods in TcaSchema and do not couple this class to FormEngine or DataHandler.NumberFieldType.php:62The scale is only valid for format decimal, otherwise it is 0 -
Daniel Windloff commented on patch set 5 09/11/26, 09:16
Sorry for the step-by-step response, I’ve given this some more thought. I don’t think the design of the `NumberFieldType` class is optimal, as `scale` is only valid for one specific format. From my perspective, one of the following approaches would be better: a) Use two TCA types: one for integers and one for floats. That way, only the decimal type would have the method getScale() for handling decimal places. The `format` option could vanish in both types. b) Remove `getFormat` from the class and the `format` option from the TCA. The number of decimal places would then determine whether it is an integer or a float. A TCA migration could migrate the `integer` format to 0 decimal places and the `decimal` format to 2 decimal places. Both TCA migrations only apply, if no `scale` is set. Format will be removed via TCA migration as well. Either approach would resolve the issue of the class configuration of `NumberFieldType` being over-specified. What do you think? -
Daniel Windloff commented on patch set 5 CR -1 09/12/26, 06:39
On it -
Daniel Windloff uploaded patch set 6
CR -1V +109/13/26, 04:35 -
core-ci voted on patch set 6 V -1 09/13/26, 04:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108436
-
Daniel Windloff uploaded patch set 7
V -109/13/26, 05:25 -
core-ci voted on patch set 7 V -1 09/13/26, 05:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108440
-
Daniel Windloff uploaded patch set 8
V -109/13/26, 06:25 -
core-ci voted on patch set 8 V +1 09/13/26, 06:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108441
-
Daniel Windloff commented on patch set 8 09/13/26, 06:34
Reply
DoneReply
DoneNumberFieldType.php:59ReplyDoneNumberFieldType.php:62ReplyDone -
Benni Mack uploaded patch set 9
V +109/30/26, 08:18 -
Benni Mack commented on patch set 9 09/30/26, 08:20
Reply
Hey, I'm gonna reopen this. I wonder if the "scale" is actually the right term for this. As "precision" fits much better, or even "fraction" or "digits". WDYT? -
core-ci voted on patch set 9 V +1 09/30/26, 08:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109595
-
Garvin Hicking commented on patch set 9 09/30/26, 08:39
Reply
My personal order of preference: digits > precision > fraction > scalevalue-slider.ts:75ReplyDone -
Benni Mack commented on patch set 9 09/30/26, 09:52
Reply
double-checked. "scale" is correct, also used in Doctrine DBAL and SQL, so we're good. -
Benni Mack commented on patch set 9 CR +1 V +1 09/30/26, 09:52
we'll handle EXT:filemetadata separately. Patch is finally good to go. -
Garvin Hicking voted on patch set 9 CR +2 V +2 09/30/26, 09:54
-
Garvin Hicking merged patch set 10 09/30/26, 09:54
-
Markus Klein commented on patch set 10 11/04/26, 23:16
DefaultTcaSchema.php:891This is a breaking change. Suddenly number fields with format 'decimal', which had no scale defined, will be assumed to scale=0 and therefore changed to integer in DB. The test here, written before this change, fails now: https://review.typo3.org/c/Packages/TYPO3.CMS/+/96120/4/typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaTest.php#3397 -
Markus Klein commented on patch set 10 11/04/26, 23:18
DefaultTcaSchema.php:891ReplyI overlooked the TCA Migration. screw that comment.