Skip to content

Commit

Permalink
[BUGFIX] FormEngine: Minor spelling and syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lolli42 committed Feb 14, 2017
1 parent b74d9af commit b40e91a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
57 changes: 30 additions & 27 deletions Documentation/ApiOverview/FormEngine/DataCompiling/Index.rst
Expand Up @@ -26,15 +26,15 @@ knows by its :code:`GET` or :code:`POST` parameters which record ("vanillaUid")
should be edited (command="edit") or created (command="new"), and sets this as init data to the DataCompiler. The
controller also knows that it should render a full database record and not only parts of it, so it uses the
:php:`TcaDatabaseRecord` data provider group to trigger all data providers relevant for this case. By calling :php:`->compile()`
on this data group calls all providers configured for this group are called after each other, and :php:`formData` ends up
with a huge array of data details.
on this data group, all providers configured for this group are called after each other, and :php:`formData` ends up
with a huge array of data record details.


So, what happens here in detail?

* Variable :php:`$formDataCompilerInput` maps input values to keys specified by :php:`FormDataCompiler` as "init" data.

* FormDataCompiler returns a unified array of data.This array is enriched by single data providers.
* FormDataCompiler returns a unified array of data. This array is enriched by single data providers.

* A data provider group is a list of single data providers for a specific scope and enriches the array with information.

Expand All @@ -45,23 +45,23 @@ The variable :php:`$formData` roughly consists of this data after calling :php:`

* A validated and initialized list of current database row field variables.

* A processed version of $TCA of given table containing only those columns fields given user has access to.
* A processed version of :php:$TCA['givenTable'] containing only those columns fields current user has access to.

* A processed list of items for single fields like select and group type columns.
* A processed list of items for single fields like select and group types.

* A list of relevant localizations.

* Information of expanded :code:`inline` record details if needed.

* Resolved flex form data structures and data
* Resolved flex form data structures and data.

* A lot more


Basic goal of this step is to create an array in a specified format with all data needed by the render-part of FormEngine.
A controller initializes this with init data, and then lets single data providers fetch additional data and write it
to the main array. The deal is here that the data within that array is *not* structured in an arbitrary way, and each single
data provider only adds data the render part of FormEngine understands later. This is why the main array keys are restricted:
data provider only adds data the render part of FormEngine understands and needs later. This is why the main array keys are restricted:
The main array is initialized by :php:`FormDataCompiler`, and each :php:`DataProvider` can only add data to sub-parts of that array.

.. note::
Expand All @@ -70,16 +70,16 @@ The main array is initialized by :php:`FormDataCompiler`, and each :php:`DataPro

.. note::
It may happen in future versions of FormEngine with core version 9, the responsibility for the main structure and integrity
of the data array is moved away from :php:`FormDataCompiler` into the single :php:`FormDataGroup`s. This may even obsolete
of the data array is moved away from :php:`FormDataCompiler` into the single :php:`FormDataGroup`. This may even obsolete
the :php:`FormDataCompiler` altogether.


Data groups and providers
-------------------------

So we have this empty data array pre-set with data by a controller and then fully initialized by :php:`FormDataCompiler`,
So we have this empty data array pre-set with data by a controller and then initialized by :php:`FormDataCompiler`,
which it hands over to a specific :php:`FormDataGroup`. What are these data providers now? Data providers are single
classes that add data within the data array. They are called in a chain after each other. A :php:`FormDataGroup` has
classes that add or change data within the data array. They are called in a chain after each other. A :php:`FormDataGroup` has
the responsibility to find out which specific single data providers should be used and calls them in a specific order.

.. figure:: ../../../Images/FormEngineDataCompiling.svg
Expand All @@ -94,7 +94,7 @@ Why we need this?
The FormDataGroup's are used to manage providers for specific scopes.

* FormDataGroups know which providers should be used in a specific scope. They usually fetch a list of providers from
some global configuration array. Extensions can add own providers in this configuration array to add further data.
some global configuration array. Extensions can add own providers in this configuration array for further data munging.

* Single data providers have dependencies to each other and must be executed in a specific order. For Instance, the
PageTsConfig of a record can only be determined if the rootline of a record has been determined, which can only happen
Expand All @@ -104,16 +104,16 @@ Why we need this?
Main data groups:

TcaDatabaseRecord
List of providers used if rendering a databaes based record
List of providers used if rendering a database based record.

FlexFormSegment
List of data providers used to prepare flex form data or flex form section container data
List of data providers used to prepare flex form data and flex form section container data.

TcaInputPlaceholderRecord
List of data providers used to prepare placeholder values for :php:`type=input` and :php:`type=text` fields
List of data providers used to prepare placeholder values for :php:`type=input` and :php:`type=text` fields.

InlineParentRecord
List of data providers used to prepare data needed if an inline record is opened from within an ajax call
List of data providers used to prepare data needed if an inline record is opened from within an ajax call.

OnTheFly
A special data group that can be initialized with a list of to-execute data providers directly. In contrast to the
Expand All @@ -123,28 +123,28 @@ OnTheFly

.. note::
It is a good idea set a breakpoint at the form data result returned by the DataCompiler and to have a look at
the data array to get an idea on what is hand around.
the data array to get an idea on what is in this array after compiling.


Let's have a closer look at the data providers. The main :php:`TcaDatabaseRecord` group consists mostly of three parts:

Main record data and dependencies
* Fetch record from DB or initialize a new row depending on :php:`$data['command']` being "new" or "edit", set as :php:`$data['databaseRow']`
* Fetch record from DB or initialize a new row depending on :php:`$data['command']` being "new" or "edit", set row as :php:`$data['databaseRow']`
* Add userTs and pageTsConnfig to data array
* Add table TCA as :php:`$data['processedTca']
* Add table TCA as :php:`$data['processedTca']`
* Determine record type value
* Fetch record translations and other details and add to data array

Single field processing
* Process values and items of simple types like :php:`type=input`, :php:`type=radio`, :php:`type=check` and so on. Validate
their :php:`databaseRow` values and validate and sanitize their :php:`processedTca` settings.
* Process more complex types that may have relations to other tables :php:`type=group` and :php:`type=select`, set
possible selectable items in :php:`$data['processedTca']` of the according fields, sanitize their TCA settings
* Process more complex types that may have relations to other tables like :php:`type=group` and :php:`type=select`, set
possible selectable items in :php:`$data['processedTca']` of the according fields, sanitize their TCA settings.
* Process :php:`type=inline` and :php:`type=flex` fields and prepare their child fields by using new instances of
:php:`FormDataCompiler` and adding their result to :php:`$data['processedTca']`

Post process after single field values are prepared
* Execute display conditions and remove fields from :php:`$data['processedTca']`that shouldn't be shown
* Execute display conditions and remove fields from :php:`$data['processedTca']` that shouldn't be shown.
* Determine main record title and set as :php:`$data['recordTitle']`


Expand All @@ -159,16 +159,19 @@ list to a different order.
Adding an own provider to this list means adding an array key to that array having a specification *where* the new data provider
should be added in the list. This is done by the arrays :php:`depends` and :php:`before`.

As an example, extension news uses an own data provider to do additional flex form data structure preparation. The core internal
flex provider split into two: :php:`TcaFlexPrepare` determines the data structure and parses it, :php:`TcaFlexProcess` uses the prepared
data structure, processes values and applies defaults if needed. The data provider from extension news hooks in between these two
to add some own preparation stuff with this code in :file:`ext_localconf.php`:
As an example, extension "news" uses an own data provider to do additional flex form data structure preparation. The core internal
flex preparation is already split into two providers: :php:`TcaFlexPrepare` determines the data structure and parses
it, :php:`TcaFlexProcess` uses the prepared data structure, processes values and applies defaults if needed. The data provider
from extension news hooks in between these two to add some own preparation stuff. The registration happens with this
code in :file:`ext_localconf.php`:

.. code-block:: php
// Modify flexform fields since core 8.5 via formEngine: Inject a data provider between TcaFlexPrepare and TcaFlexProcess
// Modify flexform fields since core 8.5 via formEngine: Inject a data provider
// between TcaFlexPrepare and TcaFlexProcess
if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8005000) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][\GeorgRinger\News\Backend\FormDataProvider\NewsFlexFormManipulation::class] = [
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord']
[\GeorgRinger\News\Backend\FormDataProvider\NewsFlexFormManipulation::class] = [
'depends' => [
\TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexPrepare::class,
],
Expand Down
4 changes: 2 additions & 2 deletions Documentation/ApiOverview/FormEngine/Overview/Index.rst
Expand Up @@ -43,14 +43,14 @@ The controller does two distinct things here: First, it initializes a data array
data providers of FormEngine which add all information needed for the rendering part. Then feed this data array
to the rendering part of FormEngine to end up with a result array containing all HTML, CSS and JavaScript.

In code, this basic workflow looks like:
In code, this basic workflow looks like this:

.. code-block:: php
$formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
$formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class
$formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
$formDataCompilerInput = [
'tableName' => $table,
'vanillaUid' => (int)$theUid,
Expand Down

0 comments on commit b40e91a

Please sign in to comment.