+6 votes

The default value of a column is not used when exporting to Doctrine annotations.
According to the documentation, there is no specific annotation for it, but it's possible to define it directly in the class :

/** 
   * @ORM\Column(type="string", nullable=false)
   */
  private $name = "Default name";

http://docs.doctrine-project.org/en/latest/reference/faq.html#how-can-i-add-default-values-to-a-column

in Feature Request by (480 points)
recategorized by

Thanks for info. We will add this feature in one of future release.

+1 for default values being translated from ORMD to Doctrine2 PHP annotations. Well, not annotations exactly because as Ludek says above they aren't supported but they can be achieved via property setting.

:)

Hi!
When this feature will be implemented? We are evaluating the software and it would be very important to us.
Thanks!

1 Answer

0 votes

Hi,
We have discussed this feature again and evaluated possible ways how to implement it. To achieve this functionality would mean that ORM Designer would have to modify the PHP code (not only the @ORM annotations as is the current state).

ORM Designer does not allow for this due to security reasons. And because this change would mean huge changes in the architecture of ORM Designer, we have to abandon this feature for now. Unfortunately we do not plan to implement it in the near future.

by Skipper developer (74.8k points)

Hi,

It seems there is an option called default - you could support this its working, but skipper of course overwrites my changes.

http://stackoverflow.com/a/11776153/151097

eg

/**
 * @ORM\Column(type="boolean", nullable=false, options={"default":0})
 */
private $public;

Thanks for posting this. We have a plans to add it to next release.

Waiting for that, the trick is to add an default option in Doctrine2.skipper.cfg.xml

like this :

<struct name="options" help-text= "" help-url="">
      <attribute name="version" type="string" help-text= "" help-url=""/>
      <attribute name="comment" type="string" help-text= "" help-url=""/>
      <attribute name="unsigned" type="bool" help-text= "" help-url=""/>
      <attribute name="default" type="string" help-text= "" help-url=""/>
</struct>

Yes, you can use it also by this way, but in this case you need to enter default value via property-editor and not via "default" column in table editor. We want to implement the second way.