[PR #311] Proposal: Support for default attribute in yaml mappings. #8012

Closed
opened 2026-01-22 15:57:58 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/311

State: closed
Merged: Yes


There's probably a very good reason you don't already do this... please let me know if there is!

The EntityGenerator supports writing a default value for a property/column when generating a class, but the yaml driver doesn't pick this up. This tiny change makes it work - you can do something like:

Acme\MyBundle\Entity\MyObject:
  type: entity
  table: my_object
  fields:
    active:
      type: boolean
      default: true

and you end up with..

/**
 * @var boolean $active
 */
private $active = true;

Similar change would also work for the other drivers I guess.

**Original Pull Request:** https://github.com/doctrine/orm/pull/311 **State:** closed **Merged:** Yes --- There's probably a very good reason you don't already do this... please let me know if there is! The EntityGenerator supports writing a default value for a property/column when generating a class, but the yaml driver doesn't pick this up. This tiny change makes it work - you can do something like: ``` Acme\MyBundle\Entity\MyObject: type: entity table: my_object fields: active: type: boolean default: true ``` and you end up with.. ``` /** * @var boolean $active */ private $active = true; ``` Similar change would also work for the other drivers I guess.
admin added the pull-request label 2026-01-22 15:57:58 +01:00
admin closed this issue 2026-01-22 15:57:58 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#8012