Skip to content

CollectionField->setEntrytostringMethod() fails when creating prototype (value is NULL) #7597

@xenatis

Description

@xenatis

Description:
Bug when using setEntrytoStringMethod on a CollectionField.

In the Twig block collection_entry_row (form_theme.html.twig), when generating the prototype, the parameter value is NULL.

How to reproduce:

        yield CollectionField::new('recipes')
        ->setEntryToStringMethod(fn():string => 'Test') //OK
        ->setEntryToStringMethod('getName') //Error
        ->setEntrytostringMethod(fn(Recipe $recipe):string => $recipe->getName().' test') // Error

Solution:
In the method representAsString (EasyAdminTwigExtension.php) the test on a NULL value should be at the beginning of the method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions