Reputation: 198
I need get default value in class file
private $example_field = 0;
When I use this
example_field:
options:
default: 0
I got default database value, but when I try to persist without setting "su" I got error (column 'su' cannot be null).
Anyway,
example_field:
default: 0
Does nothing.
Upvotes: 9
Views: 22819
Reputation: 141
The correct definition for a 0 default value would be by using quotes:
example_field:
options:
default: '0'
Upvotes: 3
Reputation: 3676
Doctrine does not support the SQL 'DEFAULT' keyword:
http://docs.doctrine-project.org/en/2.1/reference/faq.html
To solve this problem, you need to set defaults in your entity's constructor. If you want the default private variable in the class file, make and use a public getter function.
You can also try to set the variable during persist in a controller.
Upvotes: 0