Review main Merged

86177[FEATURE] New TCA type "country"

Garvin Hicking CR +2 V +2 Expert +2033 −6 updated 04/18/25, 09:25

Commit message

The TCA type "country" utilizes the country API provided
with #99618 to give integrators a simple way to implement
a country selection.

This feature implements:

* FormEngine TCA handling via SelectCountryElement
* FormEngine FlexForm handling
* FormEngine JS picker/processing
* FormEngine FormData Provider
* DataHandler integration
* DBAL TableColumnType mapping
* TCA Schema integration (custom FieldType)
* RecordList integration
* DefaultConfiguration integration to formDataGroup
* Extbase TypeConverter
* Extbase DataMapper integration
* Extbase EXT:blog_example integration
* EXT:styleguide examples
* EXT:styleguide Generator for TCA tree
* Feature ReST documentation
* DatabaseIntegrity integration
* Functional and unit tests

The Country API object is enhanced with a `__toString()`
method to allow simple usage when passed on to a Fluid
template.

This patch should act as a boilerplate for other
custom TCA types.

Note that implementation of the "Country API" into
EXT:form has been implemented already, so future new
TCA types may need EXT:form adaptation, too. Also,
a custom `f:form.countrySelect` ViewHelper already exists.

A small demo extension is available:
https://github.com/garvinhicking/tca_country_example/

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 3

Files 41

Show 21 more files

Review log 5186

Show 3461 earlier messages
  1. Garvin Hicking uploaded patch set 1 09/18/24, 09:25

  2. core-ci voted on patch set 1 V +1 09/18/24, 09:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66113

  3. Garvin Hicking uploaded patch set 2 V +1 09/18/24, 09:32

  4. Garvin Hicking updated the commit message in patch set 3 09/18/24, 09:36

    follow up docs
  5. core-ci voted on patch set 3 V -1 09/18/24, 09:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66115

  6. core-ci voted on patch set 2 V -1 09/18/24, 09:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66114

  7. Garvin Hicking uploaded patch set 4 V -1 09/18/24, 11:36

    JS module and bugfix
  8. core-ci voted on patch set 4 V +1 09/18/24, 11:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66122

  9. Garvin Hicking updated the commit message in patch set 5 V +1 09/18/24, 12:07

  10. core-ci voted on patch set 5 V +1 09/18/24, 12:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66131

  11. Garvin Hicking uploaded patch set 6 V +1 09/19/24, 09:43

    Add TcaRecordTitle implementation and test
  12. core-ci voted on patch set 6 V -1 09/19/24, 09:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66192

  13. Garvin Hicking uploaded patch set 7 V -1 09/19/24, 09:59

    Some missing DB declarations
  14. Garvin Hicking uploaded patch set 8 09/19/24, 10:00

    CGL
  15. core-ci voted on patch set 7 V -1 09/19/24, 10:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66194

  16. core-ci voted on patch set 8 V +1 09/19/24, 10:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66195

  17. Georg Ringer uploaded patch set 9 V +1 01/22/25, 17:53

  18. core-ci voted on patch set 9 V -1 01/22/25, 17:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72876

  19. Georg Ringer uploaded patch set 10 V -1 01/22/25, 18:15

  20. Georg Ringer uploaded patch set 11 01/22/25, 18:18

  21. core-ci voted on patch set 10 V -1 01/22/25, 18:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72880

  22. core-ci voted on patch set 11 V +1 01/22/25, 18:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72881

  23. Georg Ringer uploaded patch set 12 V +1 01/22/25, 20:18

  24. core-ci voted on patch set 12 V -1 01/22/25, 20:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72883

  25. Georg Ringer uploaded patch set 13 V -1 01/22/25, 20:30

  26. core-ci voted on patch set 13 V +1 01/22/25, 20:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72884

  27. Garvin Hicking updated the commit message in patch set 14 V +1 01/23/25, 20:26

  28. core-ci voted on patch set 14 V +1 01/23/25, 20:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72936

  29. Garvin Hicking uploaded patch set 15 V +1 01/23/25, 21:49

    Styleguide examples required evaluation plus tests styleguide generator with random values
  30. core-ci voted on patch set 15 V +1 01/23/25, 21:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72937

  31. Garvin Hicking uploaded patch set 16 V +1 01/24/25, 08:10

    Adjust flexforms
  32. core-ci voted on patch set 16 V +1 01/24/25, 08:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72956

  33. Garvin Hicking uploaded patch set 17 V +1 01/24/25, 09:36

    Extbase implementation wip
  34. core-ci voted on patch set 17 V -1 01/24/25, 09:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72960

  35. Garvin Hicking uploaded patch set 18 V -1 01/24/25, 10:55

    CGL
  36. core-ci voted on patch set 18 V -1 01/24/25, 11:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72968

  37. Garvin Hicking uploaded patch set 19 V -1 01/24/25, 12:39

    Extbase property an data mapping
  38. core-ci voted on patch set 19 V -1 01/24/25, 12:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72971

  39. Garvin Hicking uploaded patch set 20 V -1 01/24/25, 12:57

    CGL and test fix
  40. core-ci voted on patch set 20 V +1 01/24/25, 13:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72972

  41. Garvin Hicking commented on patch set 21 V +1 01/24/25, 22:33

    Published edit on patch set 20.
  42. core-ci voted on patch set 21 V +1 01/24/25, 22:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72985

  43. Torben Hansen commented on patch set 21 01/26/25, 11:09

    SelectCountryElement.php:80

    `$table` and `$field` are not used anywhere and can be removed.

    SelectCountryElement.php:124

    This assignment must only be performed, when `$selected = true`, because else, the icon of the last item in `$selectedItems` will be used as flag icon of the select box.

    Feature-99911-NewTCATypeCountry.rst:161

    We should provide an example on how to use the counties in a CRUD scenario. Assign countries for select field in controller action: ``` $this->view->assignMultiple([ 'countries' => GeneralUtility::makeInstance(CountryProvider::class)->getAll(), ]); ``` Additionally, it should be named, that it is the responsibility of the extension developer to limit countries to the available options defined in TCA. It must also be mentioned, that extension developers must filter out non available countries when saving a record, since the TypeConverter will simply convert any provided valid alpha2 country string to a country object. As an example, if it is limited so select `DE, CH, AT` in frontend, it is still possible to save `US` as valid value to the record.

    Feature-99911-NewTCATypeCountry.rst:169

    For the Fluid example, we should also show how to define a select field for countries. Example: ``` <f:form.select property="country" options="{countries}" optionLabelField="name" optionValueField="alpha2IsoCode" value="{item.country.alpha2IsoCode}" /> ``` Is must be mentioned, that the property `country` is providing a `TYPO3\CMS\Core\Country\Country` object, which is not an extbase dopmain model and thereby works different when used in a fluid form. The example above shows, that getters are named different (e.g. `getAlpha2` does not exist but `getAlpha2IsoCode` is available instead). Additionally, the `TYPO3\CMS\Core\Country\Country` object has no `__toString` function, which requires special value assignment when used as property in a fluid select field (see example). Should we maybe add a `__toString` method to the class providing the `$alpha2`?
  44. Garvin Hicking commented on patch set 21 01/26/25, 12:06

    Feature-99911-NewTCATypeCountry.rst:161 Reply

    Good point! Actually I'd say we should be able to retrieve the restriction/filter from the TCA config and apply sanitization? Not sure if this should happen out of the box or only when using a Validator annotation (which needs to be added then, too), what do you think?
  45. Daniel Windloff commented on patch set 21 01/27/25, 12:54

    DataHandler.php:2430

    If only one country has been selected, why should multiple countries occur here as a comma-separated list? Furthermore, the validation, that the country is in the known list of countries should be added.

    DefaultTcaSchema.php:1030

    I suggest dropping the nullable here and creating notnull with default ''. Otherwise, the option nullable should be mentioned in the feature rst file.
  46. Garvin Hicking uploaded patch set 22 V +1 01/31/25, 16:34

    Apply code review suggestions
  47. Garvin Hicking commented on patch set 22 01/31/25, 16:38

    SelectCountryElement.php:80 Reply

    True, thanks!

    SelectCountryElement.php:124 Reply

    OMG. I stumbled accross this myself before I saw your comment and spent half an hour on getting to the root of this, only to now see you found and fixed it already. Thanks! :-*

    DataHandler.php:2430 Reply

    Good catch; this was a copy+paste from the existing select and possible forward compatibility. I added a todo note and removed this for now to not cause confusion.

    DefaultTcaSchema.php:1030 Reply

    Thank you, that is a good suggestion, changed this. Also I enlarged the field because if people add their "own" countries through the TCA abilities, 2 characters were not enough.

    Feature-99911-NewTCATypeCountry.rst:161 Reply

    We discussed this a bit. The problem of tightly coupling TCA to extbase defaults would set a precedent which is not a common pattern for now. Instead, validation by custom domain logic is preferable. I will try to work out a "best practice" example for this.

    Feature-99911-NewTCATypeCountry.rst:169 Reply

    I will adapt the example together with an example extension. Adding "__toString" also sounds interesting, I will investigate this.
  48. core-ci voted on patch set 22 V +1 01/31/25, 16:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73281

  49. Garvin Hicking uploaded patch set 23 V +1 01/31/25, 17:07

    Clarify expanding countries
  50. core-ci voted on patch set 23 V +1 01/31/25, 17:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73283

  51. Garvin Hicking uploaded patch set 24 V +1 01/31/25, 21:06

    toString method plus dummy extension
  52. core-ci voted on patch set 24 V +1 01/31/25, 21:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73293

  53. Garvin Hicking uploaded patch set 25 V +1 02/01/25, 21:20

    Rework RST
  54. Garvin Hicking commented on patch set 25 02/01/25, 21:21

    Feature-99911-NewTCATypeCountry.rst:161 Reply

    I've (hugely) reworked the ReST file and create a dummy example to showcase this. I hope I addressed all of these remarks.

    Feature-99911-NewTCATypeCountry.rst:169 Reply

    Adapted the ReST and added `__toString`. I also point to the existing f:form.countrySelect VH which does the population of the options.
  55. core-ci voted on patch set 25 V +1 02/01/25, 21:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73319

  56. Georg Ringer voted on patch set 25 CR +1 V +1 02/03/25, 18:39

  57. Georg Ringer uploaded patch set 26 CR +1 V +1 02/18/25, 18:25

  58. core-ci voted on patch set 26 V -1 02/18/25, 18:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74341

  59. Georg Ringer uploaded patch set 27 V -1 02/18/25, 19:25

  60. core-ci voted on patch set 27 V +1 02/18/25, 19:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74344

  61. Simon Schaufelberger commented on patch set 27 03/23/25, 19:29

    @gh@faktor-e.de Can you please rebase?
  1. Garvin Hicking uploaded patch set 28 V +1 03/24/25, 16:55

  2. core-ci voted on patch set 28 V -1 03/24/25, 17:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76154

  3. Garvin Hicking uploaded patch set 29 V -1 03/24/25, 17:14

  4. core-ci voted on patch set 29 V +1 03/24/25, 17:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76157

  5. Garvin Hicking commented on patch set 29 03/24/25, 17:24

    Reply

    Done
  6. Garvin Hicking commented on patch set 29 03/27/25, 16:12

  7. Benni Mack uploaded patch set 30 V +1 03/27/25, 20:14

  8. core-ci voted on patch set 30 V -1 03/27/25, 20:23 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76503

  9. Benni Mack uploaded patch set 31 V -1 03/27/25, 20:33

  10. core-ci voted on patch set 31 V -1 03/27/25, 20:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76506

  11. Benni Mack uploaded patch set 32 V -1 03/27/25, 20:47

  12. core-ci voted on patch set 32 V -1 03/27/25, 20:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76511

  13. Garvin Hicking uploaded patch set 33 V -1 03/28/25, 08:29

  14. core-ci voted on patch set 33 V +1 03/28/25, 08:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76556

  15. Garvin Hicking uploaded patch set 34 V +1 04/01/25, 09:02

  16. Garvin Hicking commented on patch set 34 04/01/25, 09:03

    Reply

    Actually the main bug with icons as already addressed inside the variant of the SelectElement here, so no need for more.
  17. core-ci voted on patch set 34 V +1 04/01/25, 09:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76765

  18. Garvin Hicking rebased onto patch set 35 V +1 04/01/25, 16:25

  19. core-ci voted on patch set 35 V +1 04/01/25, 16:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76803

  20. Benni Mack voted on patch set 35 CR +1 V +1 04/01/25, 18:37

  21. Georg Ringer voted on patch set 35 CR +2 V +2 04/02/25, 04:38

  22. Georg Ringer merged patch set 36 04/02/25, 04:38

  23. Benjamin Franzke commented on patch set 36 04/02/25, 07:10

    DefaultTcaSchema.php:1047

    The field is nullable, it should have `null` as default (that means `default` can be omitted), right?
  24. Garvin Hicking commented on patch set 36 04/02/25, 07:38

    DefaultTcaSchema.php:1047 Reply

  25. Lina Wolf commented on patch set 36 04/18/25, 09:25