[Neos] Typo3.Form Neos Question
Bastian Waidelich
bastian at typo3.org
Wed May 21 18:44:43 CEST 2014
nikos wrote:
Hi Nikos,
> [...] I am wondering what is the best way to display a link back to display the form again
Just take a look at the provided finishers. The ConfirmationFinisher
demonstrates how to return a custom message, the RedirectFinisher shows
how to retrieve the current request (that you would need to create a
proper link).
If you combine this you can create a custom finisher and do s.th. like:
$formRuntime = $this->finisherContext->getFormRuntime();
$uriBuilder = new \TYPO3\Flow\Mvc\Routing\UriBuilder();
$uriBuilder->setRequest($formRuntime->getRequest());
$formUri = $uriBuilder->uriFor('index');
$response = $formRuntime->getResponse();
$response->setContent(sprintf('<a href="%s">Back</a>', $formUri));
Better yet, use Fluid to render the message and link. I've created a
simple "FluidFinisher" that you could use/adjust:
https://gist.github.com/bwaidelich/cd696fb99c1882561e0b
BUT: Because even multi-step forms work stateless (that means the values
are not persisted in a session but always encoded in the so called "form
state" that is passed on from page to page) the values will be gone if
you only link to the first page.
If you want to keep the values you should create a form instead. Let me
know if you need help with that..
I'm wondering though whether redisplaying the form is a good idea in
your case:
> The use case I am thinking of is when I am using an EmailFinisher and
> there is an error e.g. can't connect to the smtp email server.
If it's really an unexpected error like this one, it's quite likely that
the same error still occurs if you send the exact same data a few
seconds later..
Instead you could create a simple finisher that stores the form data in
a more reliable backend (the database or some csv file for example).
That way - even when sending the email fails - you can recover the form
data and/or try resending it at a later time.
HTH
--
Bastian Waidelich
More information about the Neos
mailing list