Skip to content

Commit 9676bbb

Browse files
authored
[Form] Add PHP Attributes example to forms
1 parent a85c441 commit 9676bbb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

forms.rst

+17
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)