mfmeds
(MF Med)
November 6, 2018, 4:09pm
1
Hi Guys,
i wanted to build a (MultiLanguage) Contact form with a finisher, forward to a node(site) (With an Identifier)
I did not find anything to do that, so I built my own finsher.
Here is my finisher code:
The code for the redirect is a bit tricky, is there any better solution? For example
$context = $this->contextFactory->create(
[
‘workspaceName’ => ‘live’,
‘dimensions’ => [ ‘language’ => [(string)$this->i18nService->getConfiguration()->getCurrentLocale()] ],
]
);
Thanks in Advanced!
bwaidelich
(Bastian Waidelich)
November 7, 2018, 2:54pm
2
You don’t need a custom finisher for that.
If you use neos/form-builder
you can just use Fusion to set the uri
option of the RedirectFinisher:
prototype(Some.ContactForm:Contact) < prototype(Neos.Form.Builder:Form) {
@context.redirectUri = Neos.Neos:NodeUri {
node = ${q(site).find('#some-identifier').get(0)}
}
presetName = 'bootstrap'
firstPage {
elements {
name = Neos.Form.Builder:MultiLineText.Definition {
label = 'Name'
}
}
}
finishers {
redirectFinisher = Neos.Form.Builder:RedirectFinisher.Definition {
options {
uri = ${redirectUri}
}
}
}
}
If you don’t use the form-builder package but define your forms via YAML you don’t have that flexibility directly, but you can use the overrideConfiguration
property of the Form Prototype to achieve the same:
prototype(Neos.NodeTypes.Form:Form) {
overrideConfiguration {
renderables = Neos.Fusion:RawArray {
finishers = Neos.Fusion:RawArray {
# assumes that the RedirectFinisher is your first finisher!
0 = Neos.Fusion:RawArray {
uri = Neos.Neos:NodeUri {
node = ${q(site).find('#some-identifier').get(0)}
}
}
}
}
}
}
1 Like
mfmeds
(MF Med)
November 13, 2018, 10:52am
3
Thanks for your answer,
I tried that, but I do not get it like in your example
I become this error
https://imgur.com/a/0skw1sM
Here is the Log file.
log
Exception #1332491864 in line 202 of /var/www/myhost/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Eel_FlowQuery_FlowQuery.php: No operation which satisfies the runtime constraints found for "find".
154 Neos\Eel\FlowQuery\OperationResolver_Original::resolveOperation("find", array|1|)
153 Neos\Eel\FlowQuery\FlowQuery_Original::evaluateOperations()
152 Neos\Eel\FlowQuery\FlowQuery_Original::__call("get", array|1|)
151 call_user_func_array(array|2|, array|1|)
150 Neos\Eel\Context::call("get", array|1|)
149 Neos\Eel\ProtectedContext::call("get", array|1|)
148 Neos\Eel\Context::callAndWrap("get", array|1|)
147 Neos\Eel\CompilingEvaluator_Original::{closure}(Neos\Eel\ProtectedContext)
This file has been truncated. show original
Here is my Code in root.fusion
prototype(Neos.NodeTypes.Form:Form) {
overrideConfiguration {
renderables = Neos.Fusion:RawArray {
finishers = Neos.Fusion:RawArray {
# assumes that the RedirectFinisher is your first finisher!
0 = Neos.Fusion:RawArray {
uri = Neos.Neos:NodeUri {
node = ${q(site).find('#fde02d3f-6abc-4352-be2b-a1b8e04dcf9f').get(0)}
}
}
}
}
}
}
And the Finisher
finishers:
Thanks for your reply
ReneC
(Rene Rehme)
November 13, 2018, 11:12am
4
Im not sure but i think its uncached and you need to configure which context needs to be available. Try to add " site
"
@cache {
mode = 'uncached'
context {
1 = 'node'
2 = 'documentNode'
3 = 'site'
}
}
1 Like
bwaidelich
(Bastian Waidelich)
November 13, 2018, 1:13pm
5
@mfmeds like @ReneC wrote you can add site
to the context of Neos.NodeTypes.Form:Form
.
Alternatively you can write
node = ${q(node).find('#fde02d3f-6abc-4352-be2b-a1b8e04dcf9f').get(0)}
above
mfmeds
(MF Med)
November 14, 2018, 8:29am
6
Thanks guys for your help,
@bwaidelich with node i become this error: Identifier not set.
do you have a full Example? i don’t can find the fail in my Contact Form.
bwaidelich
(Bastian Waidelich)
November 14, 2018, 9:10am
7
Can you share the whole exception message and code?
I guess it is just the Form Framework complaining about a missing Form Element identifier and got nothing to do with the above.
What’s your form definition (YAML)?
mfmeds
(MF Med)
November 14, 2018, 10:34am
8
Here is my complete YAML file,
here the Exception:
and the Full log:
Exception
Exception #1329289436 in line 45 of /var/www/Myhost/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Form_Factory_ArrayFormFactory.php: Identifier not set.
135 Neos\Form\Factory\ArrayFormFactory_Original::addNestedRenderable(array|1|, Neos\Form\Core\Model\FormDefinition)
134 Neos\Form\Factory\ArrayFormFactory_Original::build(array|6|, "default")
133 Neos\Form\ViewHelpers\RenderViewHelper_Original::render("contact-form", "Neos\Form\Factory\ArrayFormFactory", "default", array|6|)
132 call_user_func_array(array|2|, array|4|)
131 Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper::callRenderMethod()
130 TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper::initializeArgumentsAndRender()
129 TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker::invoke(Neos\Form\ViewHelpers\RenderViewHelper, array|3|, Neos\FluidAdaptor\Core\Rendering\RenderingContext)
128 TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::evaluate(Neos\FluidAdaptor\Core\Rendering\RenderingContext)
This file has been truncated. show original
very thanks, best regards
bwaidelich
(Bastian Waidelich)
November 14, 2018, 11:36am
9
@mfmeds I think my example above was not entirely correct
try this
prototype(Neos.NodeTypes.Form:Form) {
overrideConfiguration {
finishers = Neos.Fusion:RawArray {
# assumes that the RedirectFinisher is your first finisher!
0 = Neos.Fusion:RawArray {
options = Neos.Fusion:RawArray {
uri = Neos.Neos:NodeUri {
node = ${q(node).find('#fde02d3f-6abc-4352-be2b-a1b8e04dcf9f').get(0)}
}
}
}
}
}
}
1 Like
mfmeds
(MF Med)
November 14, 2018, 12:04pm
10
Very Very Thanks @bwaidelich
this is all what i needed.
Works great now.
1 Like