EasyAdmin - password update form gives error on empty password

2.7k Views Asked by At

I'm using standard Symfony 4 User entity, created by make:auth and EasyAdmin 2.0.4.

When editing existing User, password field is blank (which is good).

On submitting existing User edit form, when leaving password field blank, I get following error:

Expected argument of type "string", "NULL" given at property path "password".

How to allow EasyAdmin to ignore password field on update, when its value is empty?

1

There are 1 best solutions below

1
kampfq On BEST ANSWER

Use the empty_data option to do this. Handle the empty password in your controller.

easy_admin:
    entities:
        User:
[...]
            edit:
                    - { property: 'password', type: 'text', type_options: { required: false, empty_data: '' } }