Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Feature: #97193 - New TCA type “number” #575

Merged
merged 2 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Example
'mode' => 'prepend'
'valuePicker' => [
'items' => [
['https://', 'HTTPS'],
['http://', 'HTTP'],
['HTTPS', 'https://'],
['HTTP', 'http://'],
],
],
],
Expand Down
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 number field. If set to true (default false),
adds attribute :php:`autocomplete="on"` to the number input field allowing browser auto filling the field:

.. code-block:: php
:emphasize-lines: 7

'integer_field' => [
'label' => 'Integer field',
'config' => [
'type' => 'number',
'size' => 20,
'eval' => 'null',
'autocomplete' => true
]
],
34 changes: 34 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Properties/Eval.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.. 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.

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',
],
],
18 changes: 18 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Properties/Format.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. 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`

The format property defines, which type of number should be handled. The
:php:`integer` format is a simple number, whereas the :php:`decimal` format
is a float value with two decimal places.
33 changes: 33 additions & 0 deletions Documentation/ColumnsConfig/Type/Number/Properties/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. 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>`
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.. include:: /Includes.rst.txt
.. _columns-input-properties-range:
.. _columns-number-properties-range:

=====
range
=====

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

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: array
Expand All @@ -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 number
field to the full width of the form area, use the value 50. Minimum is 10.
Default is 30.
Loading