Skip to content

Commit f245120

Browse files
committed
minor #15001 [Form] Add PHP Attributes example to forms (wkania)
This PR was merged into the 5.2 branch. Discussion ---------- [Form] Add PHP Attributes example to forms <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `5.x` for features of unreleased versions). --> Commits ------- 6280192 [Form] Add PHP Attributes example to forms
2 parents 9a37b34 + 6280192 commit f245120

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

forms.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,23 @@ object.
507507
protected $dueDate;
508508
}
509509
510+
.. code-block:: php-attributes
511+
512+
// src/Entity/Task.php
513+
namespace App\Entity;
514+
515+
use Symfony\Component\Validator\Constraints as Assert;
516+
517+
class Task
518+
{
519+
#[Assert\NotBlank]
520+
public $task;
521+
522+
#[Assert\NotBlank]
523+
#[Assert\Type(\DateTime::class)]
524+
protected $dueDate;
525+
}
526+
510527
.. code-block:: yaml
511528
512529
# config/validator/validation.yaml

0 commit comments

Comments
 (0)