@@ -329,7 +329,7 @@ Some constraints, like :doc:`NotBlank </reference/constraints/NotBlank>`,
329
329
are simple whereas others, like the :doc: `Choice </reference/constraints/Choice >`
330
330
constraint, have several configuration options available. Suppose that the
331
331
``Author `` class has another property called ``gender `` that can be set to either
332
- "male" or "female ":
332
+ "male", "female", or "other ":
333
333
334
334
.. configuration-block ::
335
335
@@ -344,7 +344,7 @@ constraint, have several configuration options available. Suppose that the
344
344
{
345
345
/**
346
346
* @Assert\Choice(
347
- * choices = { "male", "female" },
347
+ * choices = { "male", "female", "other" },
348
348
* message = "Choose a valid gender."
349
349
* )
350
350
*/
@@ -359,7 +359,7 @@ constraint, have several configuration options available. Suppose that the
359
359
AppBundle\Entity\Author :
360
360
properties :
361
361
gender :
362
- - Choice : { choices: [male, female], message: Choose a valid gender. }
362
+ - Choice : { choices: [male, female, other ], message: Choose a valid gender. }
363
363
# ...
364
364
365
365
.. code-block :: xml
@@ -376,6 +376,7 @@ constraint, have several configuration options available. Suppose that the
376
376
<option name =" choices" >
377
377
<value >male</value >
378
378
<value >female</value >
379
+ <value >other</value >
379
380
</option >
380
381
<option name =" message" >Choose a valid gender.</option >
381
382
</constraint >
@@ -404,7 +405,7 @@ constraint, have several configuration options available. Suppose that the
404
405
// ...
405
406
406
407
$metadata->addPropertyConstraint('gender', new Assert\Choice(array(
407
- 'choices' => array('male', 'female'),
408
+ 'choices' => array('male', 'female', 'other' ),
408
409
'message' => 'Choose a valid gender.',
409
410
)));
410
411
}
@@ -429,7 +430,7 @@ options can be specified in this way.
429
430
class Author
430
431
{
431
432
/**
432
- * @Assert\Choice({"male", "female"})
433
+ * @Assert\Choice({"male", "female", "other" })
433
434
*/
434
435
protected $gender;
435
436
@@ -442,7 +443,7 @@ options can be specified in this way.
442
443
AppBundle\Entity\Author :
443
444
properties :
444
445
gender :
445
- - Choice : [male, female]
446
+ - Choice : [male, female,other ]
446
447
# ...
447
448
448
449
.. code-block :: xml
@@ -458,6 +459,7 @@ options can be specified in this way.
458
459
<constraint name =" Choice" >
459
460
<value >male</value >
460
461
<value >female</value >
462
+ <value >other</value >
461
463
</constraint >
462
464
</property >
463
465
@@ -483,7 +485,7 @@ options can be specified in this way.
483
485
484
486
$metadata->addPropertyConstraint(
485
487
'gender',
486
- new Assert\Choice(array('male', 'female'))
488
+ new Assert\Choice(array('male', 'female', 'other' ))
487
489
);
488
490
}
489
491
}
0 commit comments