Skip to content

Commit

Permalink
[TASK] Overhaul check type (#996)
Browse files Browse the repository at this point in the history
* Correct indentation,
* add names for confvals

releases: main, 12.4, 11.5

(cherry picked from commit d04eff9)
  • Loading branch information
linawolf committed Mar 26, 2024
1 parent fb7238f commit 08bad8a
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 223 deletions.
34 changes: 17 additions & 17 deletions Documentation/ColumnsConfig/Type/Check/Default.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt

.. _columns-check-properties:
.. _columns-check-properties-type:
.. _columns-check-default:
.. _columns-check-properties:
.. _columns-check-properties-type:
.. _columns-check-default:

================
Default checkbox
Expand All @@ -13,55 +13,55 @@ is typically a single checkbox or a group of checkboxes.

Its state can be inverted via :php:`invertStateDisplay`.

.. _columns-check-examples:
.. _columns-check-examples-single:
.. _columns-check-examples-array:
.. _columns-check-examples:
.. _columns-check-examples-single:
.. _columns-check-examples-array:

Examples
--------

All examples listed here can be found in the :ref:`extension styleguide
<tca_examples_extension_styleguide>`.

.. _tca_example_checkbox_2:
.. _tca_example_checkbox_2:

Example: Simple checkbox with label
-----------------------------------

.. include:: /Images/Rst/Checkbox2.rst.txt
.. include:: /Images/Rst/Checkbox2.rst.txt

TCA:

.. include:: /CodeSnippets/Checkbox2.rst.txt
.. include:: /CodeSnippets/Checkbox2.rst.txt

If the checkbox is checked, the value for the field will be 1,
if unchecked, it will be 0.

:ref:`FlexForm <t3coreapi:flexforms>`:

.. include:: /CodeSnippets/Manual/FlexformCheckbox2.rst.txt
.. include:: /CodeSnippets/Manual/FlexformCheckbox2.rst.txt

.. _tca_example_checkbox_12:
.. _tca_example_checkbox_12:

Example: Four checkboxes in three columns
-----------------------------------------

.. include:: /Images/Rst/Checkbox12.rst.txt
.. include:: /Images/Rst/Checkbox12.rst.txt

TCA:

.. include:: /CodeSnippets/Checkbox12.rst.txt
.. include:: /CodeSnippets/Checkbox12.rst.txt

If all checkboxes are checked, the value for the field will be 15 (:php:`1 | 2 | 4 | 8`).


.. _tca_example_checkbox_16:
.. _tca_example_checkbox_16:

Example: Checkboxes with inline floating
----------------------------------------

.. include:: /Images/Rst/Checkbox16.rst.txt
.. include:: /CodeSnippets/Checkbox16.rst.txt
.. include:: /Images/Rst/Checkbox16.rst.txt
.. include:: /CodeSnippets/Checkbox16.rst.txt

This will display as many checkbox items as will fit in one row. Without inline,
each checkbox would be displayed in a separate row.
42 changes: 21 additions & 21 deletions Documentation/ColumnsConfig/Type/Check/Index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt

.. _columns-check:
.. _columns-check:

==========
Checkboxes
Expand All @@ -15,7 +15,7 @@ This type creates checkbox(es).
There can be between 1 and 31 checkboxes. The corresponding database field must be of type integer.
Each checkbox corresponds to a single bit of the integer value, even if there is only one checkbox.

.. tip::
.. tip::
This means that you should check the bits of values from single-checkbox
fields and not just whether it is true or false.

Expand All @@ -25,30 +25,30 @@ fields with the render type
details please see: :ref:`selectCheckBox-check-compared`.


.. include:: /Images/Rst/Checkbox2.rst.txt
.. include:: /Images/Rst/Checkbox16.rst.txt
.. include:: /Images/Rst/Checkbox19.rst.txt
.. include:: /Images/Rst/Checkbox17.rst.txt
.. include:: /Images/Rst/Checkbox2.rst.txt
.. include:: /Images/Rst/Checkbox16.rst.txt
.. include:: /Images/Rst/Checkbox19.rst.txt
.. include:: /Images/Rst/Checkbox17.rst.txt

.. _columns-check-introduction:
.. _columns-check-introduction:

.. warning::
.. warning::
Resorting the 'items' of a type='check' config results in single items moving to different bit positions.
It might be required to migrate existing field data if doing so.

The following renderTypes are available:

* :ref:`default <columns-check-default>`: One or more checkboxes are displayed.
* :ref:`checkboxToggle <columns-check-checkboxToggle>`: Instead of checkboxes,
a toggle item is displayed.
* :ref:`checkboxLabeledToggle <columns-check-checkboxLabeledToggle>`: A toggle
switch where both states can be labelled (ON/OFF, Visible / Hidden or alike).
Its state can be inverted via :code:`invertStateDisplay`
* :ref:`default <columns-check-default>`: One or more checkboxes are displayed.
* :ref:`checkboxToggle <columns-check-checkboxToggle>`: Instead of checkboxes,
a toggle item is displayed.
* :ref:`checkboxLabeledToggle <columns-check-checkboxLabeledToggle>`: A toggle
switch where both states can be labelled (ON/OFF, Visible / Hidden or alike).
Its state can be inverted via :code:`invertStateDisplay`

.. toctree::
:hidden:
.. toctree::
:hidden:

Default
Toggle
LabeledToggle
Properties/Index
Default
Toggle
LabeledToggle
Properties/Index
16 changes: 8 additions & 8 deletions Documentation/ColumnsConfig/Type/Check/LabeledToggle.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt

.. _columns-check-checkboxLabeledToggle:
.. _columns-check-checkboxLabeledToggle:

=======================
Labeled toggle checkbox
Expand All @@ -18,24 +18,24 @@ Its state can be inverted via :ref:`invertStateDisplay
Examples
========

.. _tca_example_checkbox_19:
.. _tca_example_checkbox_19:

Single checkbox with labeled toggle
-----------------------------------

.. include:: /Images/Rst/Checkbox19.rst.txt
.. include:: /Images/Rst/Checkbox19.rst.txt

.. include:: /CodeSnippets/Checkbox19.rst.txt
.. include:: /CodeSnippets/Checkbox19.rst.txt



.. _tca_example_checkbox_21:
.. _tca_example_checkbox_21:

Single checkbox with labeled toggle inverted state display
----------------------------------------------------------

.. include:: /Images/Rst/Checkbox21.rst.txt
.. include:: /Images/Rst/Checkbox21.rst.txt

.. include:: /CodeSnippets/Checkbox21.rst.txt
.. include:: /CodeSnippets/Checkbox21.rst.txt


32 changes: 16 additions & 16 deletions Documentation/ColumnsConfig/Type/Check/Properties/Cols.rst
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
.. include:: /Includes.rst.txt
.. _columns-check-properties-cols:
.. include:: /Includes.rst.txt
.. _columns-check-properties-cols:

====
cols
====

.. confval:: cols
.. confval:: cols
:name: check-cols
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: integer/string
:Scope: Display

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: integer/string
:Scope: Display
In how many columns the checkboxes will be shown. Makes sense only if the 'items' property is defining multiple
checkboxes.

In how many columns the checkboxes will be shown. Makes sense only if the 'items' property is defining multiple
checkboxes.
Allowed values are 1, 2, 3, ..., 31 or `inline`, 1 being default. If set to `inline` the checkboxes are
"floating" and there will be as many in one row as fits to browser width.

Allowed values are 1, 2, 3, ..., 31 or `inline`, 1 being default. If set to `inline` the checkboxes are
"floating" and there will be as many in one row as fits to browser width.

Note checkboxes will still wrap if browser width is not sufficient.
Note checkboxes will still wrap if browser width is not sufficient.

Examples
========

Fixes columns
-------------

.. include:: /Images/Rst/Checkbox2.rst.txt
.. include:: /CodeSnippets/Checkbox2.rst.txt
.. include:: /Images/Rst/Checkbox2.rst.txt
.. include:: /CodeSnippets/Checkbox2.rst.txt

Inline columns
--------------

.. include:: /Images/Rst/Checkbox16.rst.txt
.. include:: /CodeSnippets/Checkbox16.rst.txt
.. include:: /Images/Rst/Checkbox16.rst.txt
.. include:: /CodeSnippets/Checkbox16.rst.txt
72 changes: 36 additions & 36 deletions Documentation/ColumnsConfig/Type/Check/Properties/Default.rst
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
.. include:: /Includes.rst.txt
.. _columns-check-properties-default:
.. include:: /Includes.rst.txt
.. _columns-check-properties-default:

=======
default
=======

.. confval:: default

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

The default value of the checkbox(es).

Each bit of the decimal value corresponds to a checkbox. As an example, the
value `5` enables the first and third checkbox.

This is true even if there is only one checkbox, which then maps to the first
bit (reading from right to left).

+---------------+-----------------------+---------------------+
| decimal value | binary representation | selected checkboxes |
+===============+=======================+=====================+
| 0 | 0000 0000 | none |
+---------------+-----------------------+---------------------+
| 1 | 0000 0001 | first |
+---------------+-----------------------+---------------------+
| 2 | 0000 0010 | second |
+---------------+-----------------------+---------------------+
| 5 | 0000 0101 | first, third |
+---------------+-----------------------+---------------------+
| 127 | 0111 1111 | the first seven |
+---------------+-----------------------+---------------------+

To find out the right default decimal value, first start off by writing down
the binary representation and set the desired bits at the appropriate
position to 1. Then convert the binary number to decimal. You can either use
a calculator with programmer mode or search online for "binary to decimal".
.. confval:: default
:name: check-default
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: integer
:Scope: Display / Proc.

The default value of the checkbox(es).

Each bit of the decimal value corresponds to a checkbox. As an example, the
value `5` enables the first and third checkbox.

This is true even if there is only one checkbox, which then maps to the first
bit (reading from right to left).

+---------------+-----------------------+---------------------+
| decimal value | binary representation | selected checkboxes |
+===============+=======================+=====================+
| 0 | 0000 0000 | none |
+---------------+-----------------------+---------------------+
| 1 | 0000 0001 | first |
+---------------+-----------------------+---------------------+
| 2 | 0000 0010 | second |
+---------------+-----------------------+---------------------+
| 5 | 0000 0101 | first, third |
+---------------+-----------------------+---------------------+
| 127 | 0111 1111 | the first seven |
+---------------+-----------------------+---------------------+

To find out the right default decimal value, first start off by writing down
the binary representation and set the desired bits at the appropriate
position to 1. Then convert the binary number to decimal. You can either use
a calculator with programmer mode or search online for "binary to decimal".

Examples
========

Multiple checkboxes with a default value
----------------------------------------

.. include:: /Images/Rst/Checkbox16.rst.txt
.. include:: /Images/Rst/Checkbox16.rst.txt

Here "Tu", the second bit, is active by default.

.. include:: /CodeSnippets/Manual/CheckboxDefault.rst.txt
.. include:: /CodeSnippets/Manual/CheckboxDefault.rst.txt
38 changes: 19 additions & 19 deletions Documentation/ColumnsConfig/Type/Check/Properties/Eval.rst
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
.. include:: /Includes.rst.txt
.. _columns-check-properties-eval:
.. include:: /Includes.rst.txt
.. _columns-check-properties-eval:

====
eval
====

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

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

Configuration of field evaluation.
Keywords:

Keywords:
maximumRecordsChecked
If this evaluation is defined, the maximum number of records from the same table that can have this box
checked will be limited. If someone tries to check the box of a record beyond the allowed maximum, the
box will be unchecked automatically upon saving.

maximumRecordsChecked
If this evaluation is defined, the maximum number of records from the same table that can have this box
checked will be limited. If someone tries to check the box of a record beyond the allowed maximum, the
box will be unchecked automatically upon saving.
The actual limit is defined with the validation property :ref:`validation <columns-check-properties-validation>`.

The actual limit is defined with the validation property :ref:`validation <columns-check-properties-validation>`.
maximumRecordsCheckedInPid
Similar to :code:`maximumRecordsChecked` but with the validation scope limited to records stored in the same page.

maximumRecordsCheckedInPid
Similar to :code:`maximumRecordsChecked` but with the validation scope limited to records stored in the same page.

.. _tca_example_checkbox_7:
.. _tca_example_checkbox_7:

Examples
========

.. include:: /Images/Rst/Checkbox7.rst.txt
.. include:: /CodeSnippets/Checkbox7.rst.txt
.. include:: /Images/Rst/Checkbox7.rst.txt
.. include:: /CodeSnippets/Checkbox7.rst.txt
Loading

0 comments on commit 08bad8a

Please sign in to comment.