1

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?

cromdev
  • 27
  • 1
  • 7
  • I would imagine it is not expecting you to setup a user without a password. Kinda dangerous in the normal world. Maybe its even insisting you dont – RiggsFolly Jan 30 '19 at 12:53

1 Answers1

0

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: '' } }
kampfq
  • 56
  • 3
  • 1
    for reference, here's what I did in AdminController: ``` protected function updateAgencyEntity(Agency $entity, Form $editForm) { $postedPassword = $editForm->get('password')->getData(); if (!empty($postedPassword)) { $entity->setPassword($this->passwordEncoder->encodePassword($entity->getUser(), $postedPassword)); } parent::updateEntity($entity); } ``` – cromdev Feb 02 '19 at 17:03