TYPO3 v15 dev-main snapshot ()
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
.. include:: /Includes.rst.txt
|
||||
.. _concepts-finishers-closurefinisher:
|
||||
|
||||
================
|
||||
Closure finisher
|
||||
================
|
||||
|
||||
The "Closure finisher" can only be used in programmatically-created forms. It allows
|
||||
you to execute your own finisher code without implementing/ declaring a finisher.
|
||||
|
||||
.. contents:: Table of contents
|
||||
|
||||
.. include:: /Includes/_NoteFinisher.rst
|
||||
|
||||
.. _apireference-finisheroptions-closurefinisher-options:
|
||||
|
||||
Closure finisher option
|
||||
=======================
|
||||
|
||||
.. _apireference-finisheroptions-closurefinisher-options-closure:
|
||||
|
||||
.. confval:: closure
|
||||
:name: closurefinisher-closure
|
||||
:required: true
|
||||
:type: `?\Closure`
|
||||
:default: `null`
|
||||
|
||||
The name of the field as shown in the form.
|
||||
|
||||
.. _apireference-finisheroptions-closurefinisher:
|
||||
|
||||
Using the closure finisher programmatically
|
||||
===========================================
|
||||
|
||||
This finisher can only be used in programmatically-created forms. It allows
|
||||
you to execute your own finisher code without implementing/ declaring a finisher.
|
||||
|
||||
Code example:
|
||||
|
||||
.. literalinclude:: _codesnippets/_finisher.php.inc
|
||||
:language: php
|
||||
|
||||
This finisher is implemented in :php:`TYPO3\CMS\Form\Domain\Finishers\ClosureFinisher`.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Form\Domain\Finishers\ClosureFinisher;
|
||||
use TYPO3\CMS\Form\Domain\Model\FormDefinition;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
private function addClosureFinisher(FormDefinition $formDefinition)
|
||||
{
|
||||
|
||||
$closureFinisher = GeneralUtility::makeInstance(ClosureFinisher::class);
|
||||
$closureFinisher->setOption('closure', function ($finisherContext)
|
||||
{
|
||||
$formRuntime = $finisherContext->getFormRuntime();
|
||||
// ...
|
||||
});
|
||||
$formDefinition->addFinisher($closureFinisher);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user