submitting Form wiht PATCH method (isSubmitted()) not working

Symfony version(s) affected: 5.2.3

Description

on a Form with a PATCH method, with the http_method_override options set to true, the form isn’t marked as submitted.
The method property of the Request class is already set to POST and so it doesn’t pass the first condition of the handleRequest() method.

How to reproduce

set the http_method_override to true and the forme method to PATCH.

Possible Solution

I didn’t really look at it in details yet, but from the (dirty) debug I made, the method property of the Request class is already set to POST and so it doesn’t pass the first condition of the handleRequest() method.

Additional context

framework.yml

framework:
  secret: '%%env(APP_SECRET)%%'
  #default_locale: en
  csrf_protection: ~
  http_method_override: true

MyForm.php

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->setMethod('PATCH');
        ...

MyController

 public function edit(Request $request)
    {
        $form = $this->createForm(MyForm::class, $class);
        $form->handleRequest($request);

        if ($form->isSubmitted()) { // Always false when using PATCH, works when using POST

1 possible answer(s) on “submitting Form wiht PATCH method (isSubmitted()) not working

  1. This is probably not related to the form component but instead some kind of conflict between the http_method_override and the http_cache option (if the http_method_override where working properly, the method attribute of your request would be PATCH).