Tashkilot Symfony2 bilan ko'p muammolarga duch kelmoqda

Men Symfony2 ni o'rganyapman va muammoim bor. Kino va aktyor orasida ko'pchilik bilan aloqam bor.

Men yangi film yaratish uchun ariza yaratdim. Ushbu shaklda aktyorlar tanlash uchun tanlangan kirishim bor, lekin ko'p aktyorlar tanlaganimda, ariza "Ushbu qiymat bo'sh bo'lmasligi kerak" xatosi hosil qildi. Aktyor sinfida mening tasdig'imni o'chirganimda, men bu xatoga yo'l qo'yganim yo'q. Mening aktyorim sinfida nima uchun mening formamni tekshirish kerak?

    /*
       *  MOVIE CLASS
       *
       */    
    class Movie
        {
            //...


            /**
             * @ORM\ManyToMany(targetEntity="Actor", inversedBy="movies")
             * @ORM\JoinTable(name="movie_actor")
             */
            protected $actors;
        }

       /*
       *  ACTOR CLASS
       *
       */

        class Actor
        {

            /**
             * @ORM\Column(type="string", length="255")
             * @Assert\NotBlank()
             * @Assert\MinLength(3)
             */
            protected $firstName;

            /**
             * @ORM\Column(type="string", length="255")
             * @Assert\NotBlank()
             * @Assert\MinLength(3)
             */
            protected $lastName;

            /**
             * @ORM\Column(type="date", nullable = true)
             */
            protected $birthday;

            /**
             * @ORM\Column(type="boolean")
             * @Assert\NotBlank()
             */
            protected $sexe;


            /**
             * @ORM\ManyToMany(targetEntity="Movie", mappedBy="actors")
             * @Assert\NotNull()
             */
            protected $movies;
        }


/**
*
* MOVIE FORM 
*/
class MovieType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder
            ->add('title')
            ->add('description')
            ->add('category')
            ->add('actors', 'entity',  
            array(
                'class' => 'MyAppFilmothequeBundle:Actor',
                'query_builder' => function(EntityRepository $er)
                    {
                        return $er->createQueryBuilder('a')->orderBy('a.firstName', 'ASC');
                    },
                 'multiple' => true
            ))
            ->add('user')
        ;
    }

    public function getDefaultOptions(array $options)
    {
        return array(
        'data_class' => 'MyApp\FilmothequeBundle\Entity\Movie');
    }
    public function getName()
    {
        return 'movie';
    }
}
3

1 javoblar

Tasdiqlash bir sinfga (cheklovlar deb ataladigan) bir qator qoidalarni qo'shish orqali amalga oshiriladi. Shunda sizning arizangiz taqdim etilgan ma'lumotlarning tegishli yoki yo'qligini tekshirish uchun tegishli sinfga qo'ygan tasdiqlovlarga qaraydi. Formalar bo'limini tekshiring.

Yana bir narsa: ob'ekt maydoni "zarur" opsiyasi sukut bo'yicha "rost" ga sozlangan. Agar siz haqiqatan ham xohlasangiz, uni yolg'onchi qilib qo'ying.

0
qo'shib qo'ydi
Va rasmiy hujjatlarda ham aytilganidek, talab qilinadigan talab faqat HTML5 attributi orqali mijozlar tomonidan tekshirish uchun ishlatiladi.
qo'shib qo'ydi muallif i.am.michiel, manba