cari

Rumah  >  Soal Jawab  >  teks badan

symfony - Bagaimana untuk menukar komen berikut kepada yml?

/**
 * @ORM\Column(type="string", length=255)
 *
 * @Assert\NotBlank(message="Please enter your name.", groups={"Registration", "Profile"})
 * @Assert\MinLength(limit="3", message="The name is too short.", groups={"Registration", "Profile"})
 * @Assert\MaxLength(limit="255", message="The name is too long.", groups={"Registration", "Profile"})
 */
protected $name;
世界只因有你世界只因有你2804 hari yang lalu434

membalas semua(1)saya akan balas

  • 滿天的星座

    滿天的星座2017-05-16 16:46:02

    Anotasi Anotasi anda mengandungi dua bahagian, medan entiti (Lajur) dan peraturan pengesahan (Tegaskan), yang masing-masing perlu ditakrifkan dalam dua fail Yml dalam Symfony.

    Medan entiti:

    http://symfony.com/doc/current/book/doctrine.html

    // src/AppBundle/Resources/onfig/doctrine/EntityName.orm.yml
    
    AppBundle\Entity\EntityName:
        type: entity
        table: tableName
        // ...
        fields:
            name:
                type: string
                length: 255

    Peraturan pengesahan:

    http://symfony.com/doc/current/book/validation.html

    // src/AppBundle/Resources/config/validation.yml
    
    AppBundle\Entity\EntityName:
        properties:
            name:
                - NotBlank: { message: "Please enter your name.", groups: [Registration, Profile] }
                - MinLength: { limit: 3, message: "The name is too short.", groups: [Registration, Profile] }
                - MaxLength: { limit: 255, message: "The name is too long.", groups: [Registration, Profile] }

    balas
    0
  • Batalbalas