Skip to content

[Twig, Form Types] Form text field placeholder can not be null. Why? #37573

Closed
@dawsza

Description

@dawsza

Symfony version(s) affected: 5.1.2

Description
Form input placeholder can be empty string or false but can not be null. Why?
Another attributes like for example class can by null.

Error: Argument 1 passed to Symfony\Bridge\Twig\Extension\TranslationExtension::trans() must be of the type string, null given

How to reproduce

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', null, ['attr' => [
                'placeholder'   => null,
            ]])
        ;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions