diff --git a/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php index 6f1f3fa2..502568ea 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php +++ b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php @@ -27,6 +27,7 @@ namespace EP\EpTheme\Form; ***************************************************************/ use EP\EpTheme\Service\BookingApiService; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher; class BpnApiFinisher extends AbstractFinisher @@ -46,7 +47,16 @@ class BpnApiFinisher extends AbstractFinisher protected function executeInternal() { + $values = []; $formValues = $this->finisherContext->getFormValues(); - $this->bookingApiService->registerAddress($formValues); + $mappingOption = $this->parseOption('mapping'); + $mappings = GeneralUtility::trimExplode(',', $mappingOption, true); + foreach ($mappings as $mapping) { + [$remote, $local] = GeneralUtility::trimExplode(':', $mapping); + $values[$remote] = $formValues[$local]; + } + if (count($values) > 0) { + $this->bookingApiService->registerAddress($values); + } } -} \ No newline at end of file +} diff --git a/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml b/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml index 1f5a5a45..9289d142 100644 --- a/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml +++ b/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml @@ -10,8 +10,35 @@ TYPO3: finishersDefinition: BpnApiFinisher: implementationClassName: 'EP\EpTheme\Form\BpnApiFinisher' + formEditor: + iconIdentifier: 'form-finisher' + label: 'BusPro Finisher' + predefinedDefaults: + options: + mapping: 'lastName:text-1,firstName:text-2,gender:singleselect-1,email:email-1,street:text-3,zipCode:text-4,city:text-5,phone:telephone-1' formElementsDefinition: Form: + formEditor: + editors: + 900: + selectOptions: + 1848: + value: 'BpnApiFinisher' + label: 'BusPro Finisher' + propertyCollections: + finishers: + 1848: + identifier: 'BpnApiFinisher' + editors: + 100: + label: 'BusPro Finisher' + 110: + identifier: 'mapping' + templateName: 'Inspector-TextEditor' + label: 'Mapping' + propertyPath: 'options.mapping' + propertyValidators: + 10: 'NotEmpty' renderingOptions: templateRootPaths: 1505042810: 'EXT:ep_theme/Resources/Private/Templates/Form/' diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml index b649f8b7..b2e891ab 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml @@ -8,6 +8,8 @@ prototypeName: contactform finishers: - identifier: BpnApiFinisher + options: + mapping: 'lastName:lastName,firstName:firstName,gender:gender,email:email,street:street,zipCode:zipCode,city:city,phone:phone' - options: subject: 'Kontaktanfrage von {firstName} {lastName}'