-
-
Save egobude/a40e7fa53a5159747160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace WM\StarterKit\Finishers; | |
/** | |
* @author Benjamin Klix | die wegmeister gmbh | |
*/ | |
class EmailFinisher extends \TYPO3\Form\Finishers\EmailFinisher { | |
/** | |
* Extends the functionality of the default parseOption() method | |
* by making node-properties available | |
* | |
* @param string $optionName | |
* @return mixed|string | |
*/ | |
protected function parseOption($optionName) { | |
if (!isset($this->options[$optionName]) || $this->options[$optionName] === '') { | |
if (isset($this->defaultOptions[$optionName])) { | |
$option = $this->defaultOptions[$optionName]; | |
} else { | |
return NULL; | |
} | |
} else { | |
$option = $this->options[$optionName]; | |
} | |
if (!is_string($option)) { | |
return $option; | |
} | |
if(preg_match('/{node\.([^}]+)}/', $option, $matches)) { | |
$renderingOptions = $this->finisherContext->getFormRuntime()->getRenderingOptions(); | |
if(isset($renderingOptions['node'])) { | |
$node = $renderingOptions['node']; | |
if($node->hasProperty($matches[1])) { | |
$property = $node->getProperty($matches[1]); | |
if(!empty($property)) { | |
return $property; | |
} | |
} | |
} | |
} | |
return parent::parseOption($optionName); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{namespace form=TYPO3\Form\ViewHelpers} | |
<div{attributes -> f:format.raw()}> | |
<f:if condition="{formIdentifier}"> | |
<f:then> | |
<form:render persistenceIdentifier="{formIdentifier}" presetName="{presetName}" overrideConfiguration="{renderingOptions:{node: node}}" /> | |
</f:then> | |
<f:else> | |
<p>Please select a valid Form identifier in the inspector</p> | |
</f:else> | |
</f:if> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type: 'TYPO3.Form:Form' | |
identifier: ContactForm | |
label: Kontakt | |
renderables: | |
- | |
type: 'TYPO3.Form:Page' | |
identifier: page-one | |
renderables: | |
- | |
type: 'TYPO3.Form:SingleLineText' | |
identifier: Name | |
label: Name | |
validators: | |
- identifier: 'TYPO3.Flow:NotEmpty' | |
properties: | |
elementClassAttribute: 'form-control' | |
wrapperClassAttribute: 'form-group' | |
defaultValue: '' | |
- | |
type: 'TYPO3.Form:SingleLineText' | |
identifier: Email | |
label: EMail | |
validators: | |
- identifier: 'TYPO3.Flow:NotEmpty' | |
- identifier: 'TYPO3.Flow:EmailAddress' | |
properties: | |
elementClassAttribute: 'form-control' | |
wrapperClassAttribute: 'form-group' | |
defaultValue: '' | |
- | |
type: 'TYPO3.Form:MultiLineText' | |
identifier: Message | |
label: Message | |
validators: | |
- identifier: 'TYPO3.Flow:NotEmpty' | |
properties: | |
elementClassAttribute: 'form-control' | |
wrapperClassAttribute: 'form-group' | |
rows: 1 | |
defaultValue: '' | |
finishers: | |
- | |
identifier: 'WM.StarterKit:Email' | |
options: | |
templatePathAndFilename: resource://WM.StarterKit/Private/Templates/Email/Contact.html | |
subject: '{node.subject}' | |
senderName: '{node.senderName}' | |
senderAddress: noreply@homepage.de | |
recipientName: '{node.recipientName}' | |
recipientAddress: '{node.recipientAddress}' | |
replyToAddress: '{Email}' | |
format: html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'WM.StarterKit:ContactForm': | |
superTypes: | |
- 'TYPO3.Neos.NodeTypes:Form' | |
ui: | |
label: 'Contact Form' | |
group: general | |
icon: icon-envelope-alt | |
inspector: | |
tabs: | |
mail: | |
label: 'Contact form settings' | |
position: 11 | |
icon: icon-envelope-alt | |
groups: | |
mail: | |
label: 'Contact form settings' | |
position: 10 | |
tab: mail | |
properties: | |
subject: | |
type: string | |
defaultValue: '' | |
ui: | |
label: 'Subject' | |
inspector: | |
group: mail | |
validation: | |
'TYPO3.Neos/Validation/NotEmptyValidator': [] | |
senderName: | |
type: string | |
defaultValue: '' | |
ui: | |
label: 'Sender name' | |
inspector: | |
group: mail | |
recipientName: | |
type: string | |
defaultValue: '' | |
ui: | |
label: 'Recipient name' | |
inspector: | |
group: mail | |
validation: | |
'TYPO3.Neos/Validation/NotEmptyValidator': [] | |
recipientAddress: | |
type: string | |
defaultValue: '' | |
ui: | |
label: 'Recipient address' | |
inspector: | |
group: mail | |
validation: | |
'TYPO3.Neos/Validation/NotEmptyValidator': [] | |
'TYPO3.Neos/Validation/EmailAddressValidator': [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TYPO3: | |
Form: | |
presets: | |
default: | |
finisherPresets: | |
'WM.StarterKit:Email': | |
implementationClassName: 'WM\StarterKit\Finishers\EmailFinisher' | |
options: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment