Redirect back to edit post form

I have a page with corresponding post data like this

/* example form */
<form action="{{ url_for('update.post') }}" method="POST">

  <input type="hidden" name="_METHOD" value="PATCH">
  <input type="hidden" name="id" value="{{ post.id }}">

  <input type="text" name="title" value="{{ post.title }}">
  <input type="text" name="content" value="{{  post.content }}">

  <button type="submit">Update</button>

</form>

If validation failed, I want to redirect back with additional data like errors from validation

My route:

$app->get('/post/show/{id}', [PostController::class, 'show'])->setName('show.post');

$app->patch('/post/update', [PostController::class, 'update'])->setName('update.post');

My controller:

<?php

namespace App\Controllers;

use App\Models\Post;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;

class PostController
{
  public function __construct(protected ContainerInterface $container)
  {
  }

  public function show(Request $request, Response $response, int $id): Response
    {
      $post = Post::find($id);
      $view = $this->container->get('view');

      return $view->render($response, 'auth/post/show.twig', compact('post'));
    }

    public function update(Request $request, Response $response): Response
    {
      $postId = $request->getParsedBody()['id'];

      // validation failed
     // $errors = $validation->getErrors();

      $routeContext = RouteContext::fromRequest($request);
      $routeParser = $routeContext->getRouteParser();
      $url = $routeParser->urlFor('show.post', [
        'id' => $postId
      ]);

      return $response->withRedirect($url);
    }
}

So, how can I redirect back with additional data like errors from validation?

I’m using package slim/http

I know it’s probably voodoo in some camps to suggest, but why not use the same route for both instead of adding extra complexity?

$app->map(['GET', 'POST'], '/post/{id}', [PostController::class, 'show'])->setName('show.post');

Then handle in code whether it’s POST or not? We check for errors and if errors array is empty then send them off to destination, otherwise it stays on the page (as long as your form action keeps them there)

Yes, I could use map route there but I just want to separate method that only view template and method that has some logic/service