Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Insert POST values after createAction


I'd like to seperate index from create actions. But the POST data doesn't get inserted when the form isn't valid. Short version of my code:

public function indexAction() {
     // Set form
    $this->view->registrationForm = new RegistrationForm;

public function createAction() {
    $registrationForm = new RegistrationForm;

    // Check if post
    if ($this->request->isPost()) {
        if (!$registrationForm->isValid($this->request->getPost())) {
            foreach ($registrationForm->getMessages() as $message) {
        } else {
            // save

The error messages appear but the POST data isn't populated.


Solved it using:

$this->dispatcher->forward(['action' => 'index']);

Thanks for watching!