Home > Back-end >  symfony : textfield how to change type?
symfony : textfield how to change type?

Time:05-05

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.

CodePudding user response:

Add ->setFormType(PasswordType::class).

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