This gist is about creating your own custom finisher available for forms you create with EXT:form in TYPO3 v8.
Standard finishers let you send an email, redirect to a page, etc. This is about creating your own business logic when sending the form.
# File EXT:your_ext/Configuration/Yaml/MyCustomActionBackend.yaml | |
TYPO3: | |
CMS: | |
Form: | |
prototypes: | |
# add our finisher to the 'standard' form prototype | |
standard: | |
formElementsDefinition: | |
Form: | |
formEditor: | |
editors: | |
# 900 = 'finishers' in EXT:form/Configuration/Yaml/FormEditorSetup.yaml | |
900: | |
selectOptions: | |
# add the MyCustomAction finisher to the finishers select list | |
# "500" is to prevent overriding standard finishers which are < 100 | |
500: | |
value: 'MyCustomAction' | |
label: 'My Custom Action' | |
propertyCollections: | |
finishers: | |
# add the MyCustomAction finisher editor configurations | |
# at the moment there are no editors but this is needed anyway to "see" the | |
# finisher added to the form and being able to remove it with the delete icon | |
# "500" below has nothing to do with the "500" above but I find it more logical | |
# to use same index :) | |
500: | |
__inheritances: | |
10: 'TYPO3.CMS.Form.mixins.FormEngineCustomActionMixin' | |
identifier: 'MyCustomAction' | |
editors: | |
__inheritances: | |
10: 'TYPO3.CMS.Form.mixins.formElementMixins.BaseCollectionEditorsMixin' | |
100: | |
label: 'My Custom Action' | |
200: | |
identifier: 'yourCustomOption' | |
templateName: 'Inspector-TextEditor' | |
label: 'Your custom option' | |
propertyPath: 'options.yourCustomOption' | |
enableFormelementSelectionButton: true | |
propertyValidators: | |
10: 'NotEmpty' | |
20: 'FormElementIdentifierWithinCurlyBracesInclusive' | |
finishersDefinition: | |
MyCustomAction: | |
formEditor: | |
iconIdentifier: 't3-form-icon-finisher' | |
predefinedDefaults: | |
options: | |
yourCustomOption: '' | |
mixins: | |
FormEngineCustomActionMixin: | |
elements: | |
yourCustomOption: | |
config: | |
type: 'input' | |
<?php | |
declare(strict_types=1); | |
// File EXT:your_ext/Classes/Domain/Finishers/MyCustomActionFinisher.php | |
namespace VENDOR\YourExt\Domain\Finishers; | |
use TYPO3\CMS\Form\Domain\Finishers\Exception\FinisherException; | |
class MyCustomActionFinisher extends \TYPO3\CMS\Form\Domain\Finishers\EmailFinisher | |
{ | |
/** | |
* Executes this finisher | |
* @see AbstractFinisher::execute() | |
* | |
* @throws FinisherException | |
*/ | |
protected function executeInternal() | |
{ | |
// TODO | |
parent::executeInternal(); | |
} | |
} |
# File EXT:your_ext/Configuration/Yaml/MyCustomActionFrontend.yaml | |
TYPO3: | |
CMS: | |
Form: | |
prototypes: | |
# add our finisher to the 'standard' form prototype | |
standard: | |
finishersDefinition: | |
MyCustomAction: | |
implementationClassName: 'VENDOR\YourExt\Domain\Finishers\MyCustomActionFinisher' | |
options: | |
#yourCustomOption: '' |
# File EXT:your_ext/Configuration/TypoScript/setup.t3s | |
# or any other TypoScript file you use in your page tree | |
# Registration for the backend | |
module.tx_form { | |
settings { | |
yamlConfigurations { | |
100 = EXT:your_ext/Configuration/Yaml/MyCustomActionBackend.yaml | |
} | |
} | |
} | |
# Registration for the frontend | |
plugin.tx_form { | |
settings { | |
yamlConfigurations { | |
100 = EXT:your_ext/Configuration/Yaml/MyCustomActionFrontend.yaml | |
} | |
} | |
} |
I have TYPO3 9.x setup, I followed the same steps for my custom finisher. But, while I debug the form values in the finisher It does not show.
$formData = $this->finisherContext->getFormValues();
Can you please help.
Why are you trying to call the parent abstract method? This doesn't make any sense.
https://gist.github.com/xperseguers/5dfe069246f2aa0e7c7e418b5cccf200#file-mycustomactionfinisher-php-L21