Skip to content

[Form] group_by does not works with callable string #15542

@satanasdiabolo

Description

@satanasdiabolo

I tried to use 'group_by' option with a call to a static method.

$form = $this->createFormBuilder()
            ->add('files', 'choice', [
                'choices' => [/* Some Choices */],
                'choices_as_values' => true,
                'group_by' => 'MyStatic::method'
            ])
            ->getForm();

Here is a dummy code sample of what I'm doing.
I saw in Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator::createView line 203, the test is if (is_string($groupBy)).
I think it should be if (is_string($groupBy) && !is_callable($groupBy)).

I have test with option choice_value, and other new options, but this bug may exists for those ones too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy