Skip to content

Commit

Permalink
[FEATURE] Feature: #97193 - New TCA type “number”
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Apr 6, 2022
1 parent 33a4278 commit e9847b9
Show file tree
Hide file tree
Showing 14 changed files with 371 additions and 64 deletions.
23 changes: 2 additions & 21 deletions Documentation/ColumnsConfig/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,8 @@ be influenced by further properties.
.. toctree::
:maxdepth: 2
:titlesonly:
:glob:

Introduction/Index
CommonProperties/Index
Type/Category/Index
Type/Check/Index
Type/Color/Index
Type/Datetime/Index
Type/Email/Index
Type/Flex/Index
Type/Folder/Index
Type/Group/Index
Type/ImageManipulation/Index
Type/Inline/Index
Type/Input/Index
Type/Language/Index
Type/Link/Index
Type/None/Index
Type/Passthrough/Index
Type/Password/Index
Type/Radio/Index
Type/Select/Index
Type/Slug/Index
Type/Text/Index
Type/User/Index
Type/*/Index
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
format
======

.. confval:: format
.. confval:: format (type => datetime)

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (keyword)
Expand Down
11 changes: 4 additions & 7 deletions Documentation/ColumnsConfig/Type/Input/Properties/Eval.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ eval
Allows a domain name such as :samp:`example.org` and automatically transforms
the value to `punicode <https://en.wikipedia.org/wiki/Punycode>`_ if needed.

double2
Converts the input to a floating point with 2 decimal positions, using the "." (period) as the decimal
delimited (accepts also "," for the same).

int
Evaluates the input to an integer.

is\_in
Will filter out any character in the input string which is *not* found in the string entered in the
property :ref:`is\_in <columns-input-properties-is-in>`.
Expand Down Expand Up @@ -92,6 +85,10 @@ eval
The keyword `password` and `saltedPassword` are deprecated.
Use the column type :ref:`columns-password` instead.

.. deprecated:: 12.0
The keywords `int` and `double2` are deprecated. Use the column
type :ref:`columns-number` instead.

Examples
========

Expand Down
10 changes: 2 additions & 8 deletions Documentation/ColumnsConfig/Type/Input/Properties/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@ Special properties

.. toctree::
:titlesonly:
:glob:

Autocomplete
Eval
IsIn
Max
Range
Size
Slider
ValuePicker
*

Common properties
=================
Expand Down
22 changes: 0 additions & 22 deletions Documentation/ColumnsConfig/Type/Input/Properties/Slider.rst

This file was deleted.

91 changes: 91 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
.. include:: /Includes.rst.txt

.. _columns-number:

======
Number
======

.. versionadded:: 12.0
The TCA type :php:`number` has been introduced. It replaces the
:php:`eval=int` and :php:`eval=double2` options of TCA type :php:`input`.


The TCA type :php:`number` should be used to input values representing numbers.


.. note::

The :ref:`slider <columns-number-properties-slider>` option allows to define
a visual slider element, next to the input field. The steps can be
defined with the :ref:`slider[step] <columns-number-properties-slider>`
option. The minimum and maximum value can be configured with the
:ref:`range[lower] <columns-number-properties-range>` and
:ref:`range[upper] <columns-number-properties-range>` options.

Migration
=========

Migration from eval='int'
-------------------------

The migration from :php:`eval='int'` to :php:`type=number`
is done like following:

.. code-block:: php
// Before
'int_field => [
'label' => 'Int field',
'config' => [
'type' => 'input',
'eval' => 'int',
]
]
// After
'int_field => [
'label' => 'Int field',
'config' => [
'type' => 'number',
]
]
Migration from eval='double2'
-----------------------------

The migration from :php:`eval=double2` to :php:`type=number`
is done like following:

.. code-block:: php
// Before
'double2_field => [
'label' => 'double2 field',
'config' => [
'type' => 'input',
'eval' => 'double2',
]
]
// After
'double2_field => [
'label' => 'double2 field',
'config' => [
'type' => 'number',
'format' => 'decimal'
]
]
An automatic TCA migration is performed on the fly, migrating all occurrences
to the new TCA type and triggering a PHP :php:`E_USER_DEPRECATED` error
where code adoption has to take place.

.. toctree::
:titlesonly:

Properties/Index
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. include:: /Includes.rst.txt
.. _columns-number-properties-autocomplete:

============
autocomplete
============

.. confval:: autocomplete ('type' => 'number')

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: boolean
:Scope: Display

Controls the `autocomplete` attribute of a given email field. If set to true (default false),
adds attribute :php:`autocomplete="on"` to the email input field allowing browser auto filling the field:

.. code-block:: php
:emphasize-lines: 7
'email' => [
'label' => 'number',
'config' => [
'type' => 'number',
'size' => 20,
'eval' => 'null',
'autocomplete' => true
]
],
38 changes: 38 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Properties/Eval.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. include:: /Includes.rst.txt
.. _columns-number-properties-eval:

====
eval
====

.. confval:: eval ('type' => 'number')

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (list of keywords)
:Scope: Display / Proc.

Configuration of field evaluation.

Some of these evaluation keywords will trigger a JavaScript pre- evaluation
in the form. Other evaluations will be performed in the backend. The
evaluation functions will be executed in the list-order.

Keywords:

null
An empty value (string) will be stored as :code:`NULL` in the database,
requires a proper sql definition.

Examples
========


.. code-block:: php
'aField' => [
'label' => 'aLabel',
'config' => [
'type' => 'number',
'eval' => 'null',
],
],
14 changes: 14 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Properties/Format.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. include:: /Includes.rst.txt
.. _columns-number-properties-format:

======
format
======

.. confval:: format (type => number)

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (keyword)
:Scope: Display

Keywords: :php:`integer`, :php:`decimal`
38 changes: 38 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Properties/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. include:: /Includes.rst.txt
.. _columns-number-properties:

==========
Properties
==========

Special properties
==================

.. toctree::
:titlesonly:
:glob:

*

Common properties
=================

* :ref:`behaviour > allowLanguageSynchronization <tca_property_behaviour_allowLanguageSynchronization>`
* :ref:`default <tca_property_default>`
* :ref:`fieldControl <tca_property_fieldControl>`
* :ref:`fieldInformation <tca_property_fieldInformation>`
* :ref:`fieldWizard <tca_property_fieldWizard>` with the following options

* :ref:`defaultLanguageDifferences <tca_property_fieldwizard>`
* :ref:`localizationStateSelector <tca_property_fieldWizard_localizationStateSelector>`
* :ref:`otherLanguageContent <tca_property_fieldWizard_otherLanguageContent>`

* :ref:`mode <tca_property_mode>`
* :ref:`placeholder <tca_property_placeholder>`
* :ref:`readOnly <tca_property_readOnly>`
* :ref:`required <tca_property_required>`

.. note::

The softref definition :php:`softref=>email[subst]` is automatically applied
to all :php:`email` fields.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. include:: /Includes.rst.txt
.. _columns-input-properties-range:
.. _columns-number-properties-range:

=====
range
Expand Down Expand Up @@ -29,8 +29,13 @@ Limit an integer to be within the range 10 to 1000

.. code-block:: php
'eval' => 'int',
'range' => [
'lower' => 10,
'upper' => 1000
'aField' => [
'label' => 'aLabel',
'config' => [
'type' => 'number'
'range' => [
'lower' => 10,
'upper' => 1000
],
],
],
16 changes: 16 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Properties/Size.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. include:: /Includes.rst.txt
.. _columns-number-properties-size:

====
size
====

.. confval:: size ('type' => 'number')

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: integer
:Scope: Display

Abstract value for the width of the :code:`<input>` field. To set the email
field to the full width of the form area, use the value 50. Minimum is 10.
Default is 30.
Loading

0 comments on commit e9847b9

Please sign in to comment.