Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Prevent assign form field value

Hi all

Small issue: When I create a From for update, and assign User entity, Form loads password from model to field value. How to prevent this behavior?

    public function initialize($entity, $options)
    {
        parent::initialize($entity, $options);

        $password = new Password('password', [
            'autocomplete' => 'off',
            'class'        => 'form-control',
            'maxlength'    => 32,
            'value'        => '' // I need do this?
        ]);

        $password->setLabel('Password');
        $password->setDefault(''); // I need do this?
        $password->setUserOption('value', ''); // I need do this?

        $this->add($password);
    }

Imgur

Thanks.



24.6k
Accepted
answer

Solved:

$password->clear();