John Smith
John Smith

Reputation: 6197

Doctrine, ignore some fields to persist and null

given a user:

id, name, password

so I want to modify him, and set a name to it. But then if I persists, his password will be rewritten (set to empty), even though I didnt set it. But here is the nullable=true annotation! Right now it seems to work - but this way its impossible to persist if I want to set it null itself. Then how?

Upvotes: 0

Views: 1870

Answers (1)

angrinessfap
angrinessfap

Reputation: 474

in the password field in form add the argument mapped => false do the Doctrine will not be considered as an entity field in the moment of form validation.

->add('password', 'password', array(
   'mapped' => false
))

Upvotes: 1

Related Questions