How do I redirect a FormBuilder that's included in a view?
Created 4 years ago by daviesgeekI have a FormBuilder
like so: $builder
. I am including the form on a page with a controller like this:
return $this->view->make('module::view', ['form' => $builder->make()->getFormContent()]);
And in the view:
<h1>My Cool Form!</h1>
{{ form | raw }}
I've set the redirect option on the form:
$builder->setOption('redirect', 'my-other-page');
But I can't get the form to redirect after submission. If I return the rendered builder:
return $builder->render();
The redirect works, but not if I include it in a page like stated above. How can I do this?
You can access options and methods using the
form
function which returns a criteria instance wrapping the builder you chose. This is not documented yet but here's what to do:my_form
{{ form('my_form') }}
You can also magically resolve your form builder if your model is bound to generated one and calling form like this:
{{ form('namespace', 'stream') }}
.After that you can access methods and options in a fluent manner:
You can also set the form and use it's components in the
FormPresenter
: