I have created custom finisher to call API and send data to the server. Here is the code for this.
Typoscript:
plugin.tx_form.settings.yamlConfigurations {
200 = EXT:ApiCall/Configuration/Yaml/BaseSetup.yaml
300 = EXT:ApiCall/Configuration/Yaml/FormEngineSetup.yaml
}
module.tx_form.settings.yamlConfigurations {
200 = EXT:ApiCall/Configuration/Yaml/BaseSetup.yaml
300 = EXT:ApiCall/Configuration/Yaml/FormEditorSetup.yaml
400 = EXT:ApiCall/Configuration/Yaml/FormEngineSetup.yaml
}
BaseSetup.yaml
TYPO3:
CMS:
Form:
prototypes:
standard:
finishersDefinition:
ApiCall:
implementationClassName:
'Vendor\ApiCall\Domain\Finishers\ApiCallFinisher'
FormEditorSetup.yaml
TYPO3:
CMS:
Form:
########### FORMEDITOR CONFIGURATION ###########
prototypes:
standard:
########### DEFAULT FORM ELEMENT DEFINITIONS ###########
formElementsDefinition:
Form:
formEditor:
editors:
900:
selectOptions:
60:
value: 'ApiCall'
label: 'ApiCall'
propertyCollections:
finishers:
90:
identifier: 'ApiCall'
editors:
__inheritances:
10: 'TYPO3.CMS.Form.mixins.formElementMixins.BaseCollectionEditorsMixin'
100:
label: "ApiCall"
110:
identifier: 'url'
templateName: 'Inspector-TextEditor'
label: 'url'
propertyPath: 'options.url'
propertyValidators:
10: 'NotEmpty'
### FORM ELEMENTS: INPUT ###
Text:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
Password:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
AdvancedPassword:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
Hidden:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
Textarea:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
### FORM ELEMENTS: SELECT ###
Checkbox:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
MultiCheckbox:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
MultiSelect:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
RadioButton:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
SingleSelect:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
### FORM ELEMENTS: CUSTOM ###
DatePicker:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
### FORM ELEMENTS: UPLOADS ###
FileUpload:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
ImageUpload:
formEditor:
editors:
1000:
identifier: 'ApiCallname'
templateName: 'Inspector-TextEditor'
label: 'ApiCall field name'
propertyPath: 'properties.ApiCallname'
### FINISHERS ###
finishersDefinition:
ApiCall:
formEditor:
iconIdentifier: 't3-form-icon-finisher'
label: 'A Label that seems to be never used...'
predefinedDefaults:
options:
url: ''
FormEngineSetup.yaml
TYPO3:
CMS:
Form:
prototypes:
standard:
finishersDefinition:
ApiCall:
FormEngine:
label: "When is this label used? And for what?"
elements:
# hier nochmal alle Felder
# ich habe keine Ahnung wofür diese sind aber ohne geht es nicht
# spontan würde ich behaupten das es tca configuration ist
# aber ich definiere keine Datenbank Felder ~ vielleicht ist das aber eine Option
url: {label: url, config: {type: input}}
Set finisher.
renderingOptions:
submitButtonLabel: send
type: Form
identifier: contactform
label: 'Drop us a line and we''ll get back to you ASAP! Yes, we''re fast!'
prototypeName: standard
finishers:
-
options:
subject: 'New Inquiry'
recipientAddress: example@gmail.com
recipientName: 'Admin'
senderAddress: '{email-1}'
senderName: ' {text-1}'
replyToAddress: '{email-1}'
carbonCopyAddress: ''
blindCarbonCopyAddress: ''
format: html
attachUploads: true
identifier: EmailToReceiver
-
options:
subject: 'Inquiry - sender'
recipientAddress: '{email-1}'
recipientName: '{text-1}'
senderAddress: test@gmail.com
senderName: 'Admin'
replyToAddress: test@gmail.com
carbonCopyAddress: ''
blindCarbonCopyAddress: ''
format: html
attachUploads: true
identifier: EmailToSender
-
options:
pageUid: '21'
additionalParameters: ''
identifier: Redirect
-
options:
url: 'https://api.example.com/setdata'
identifier: ApiCall
In my finisher file, I tried to debug form data, but this not working. here is my finisher file code
<?php
namespace Vendor\ApiCall\Domain\Finishers;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
class ApiCallFinisher extends AbstractFinisher
{
protected function executeInternal()
{
DebuggerUtility::var_dump($this);
$values = $this->finisherContext->getFormValues();
DebuggerUtility::var_dump($values);die;
}
}
both debug not showing, a form is being submitted. Can anyone tell me what's wrong?
Thanks an advance!
Your finisher must be moved before the redirect finisher.
After the redirect finisher is called, your code is being stopped to perform the redirect. ✌️