symfony : textfield how to change type?

How to change the type of Textfield to force it to ‘password’ so that the content of the field does not appear when entering. I am implementing easyadmin, in symfony 6, as follows:

        TextField::new('password')
            ->hideOnIndex()
            ->setFormTypeOptions([
                'label' => 'Mot de passe',
                'attr' => ['type' => 'password'],
            ]),

Thank you in advance for your returns and very nice day to all.

>Solution :

Add ->setFormType(PasswordType::class).

TextField::new('password')
    ->hideOnIndex()
    ->setFormType(PasswordType::class)
    ->setFormTypeOptions([
        'label' => 'Mot de passe',
        'attr' => ['type' => 'password'],
    ]),

Leave a Reply