Search code examples
phpsymfony4symfony2-easyadmineasyadmin

EasyAdmin - password update form gives error on empty password


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?


Solution

  • 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: '' } }