[FLOW3-general] Flow and validation when deleting
Stephan Vidar
vidvid at freakmail.de
Tue Feb 5 16:02:39 CET 2013
Am 04.02.2013 15:24, schrieb David Sporer:
> Hi,
>
> another option is to specify default values.
>
> /** * The label color * @var string *
> @FLOW3\Validate(type="StringLength", options={"minimum"=6, "maximum"=6
> }) * @ORM\Column(options={"default" = "000000"}) */
> protected $labelColor = '000000';
>
>
> Best Regards
>
> David
Hi David,
this is a nice option but is not documented anywhere!
http://docs.doctrine-project.org/en/2.0.x/reference/annotations-reference.html#annref-column
I have read everywhere that doctrine doesn't support database default
values... but this works fine if I add this new property to model:
/**
* The country
* @var string
* @Flow\Validate(type="NotEmpty")
* @ORM\Column(options={"default" = "Spain"})
*/
protected $country = 'Spain';
After doctrine update, there is the new column 'country' and the data
sets have the default value 'Spain'.
But the following example doesn't work, if I add this new property with
ManyToOne relation to a existing label object:
/**
* The label
* @var \App\Test\Domain\Model\Label
* @ORM\ManyToOne
* @Flow\Validate(type="NotEmpty")
* @ORM\Column(options={"default" =
"87afd5ac-fdd3-4b35-b9dc-85f8fbf38950"})
*/
protected $label = '87afd5ac-fdd3-4b35-b9dc-85f8fbf38950';
After doctrine update, the data sets have value NULL.
Hmm... any idea, because that would be a nice feature!
Greets, Stephan
More information about the FLOW3-general
mailing list