2013-03-25 1 views
3

안녕하세요 내 양식의 텍스트 필드 모음에 문제가 있습니다. 필드 중 하나에 오류가있는 경우 이러한 오류는 상위 형식으로 바뀌므로 필드에 할당되지 않고 자체적으로 부모에게 할당됩니다. 다음 코드에서 'points'컬렉션입니다. error_bubbling을 false로 설정하려고 시도했지만 효과가 없습니다. 내가 form.points 이상, 더 필드에 오류가없는 반복 할 때양식 모음 오류 버블 링

 /** 
    * @Assert\Type(type="integer", message="Hodnota {{ value }} není celé číslo.") 
    * @Assert\Range(
    *  min = "0", 
    *  max = "", 
    *  minMessage = "Body nemohou být záporné", 
    *  maxMessage = "Příliš mnoho bodů" 
    *) 
    */ 
    private $points; 

나뭇 가지 템플릿에서,하지만 form.points을 수행합니다

<?php 
    namespace JamaLvova\AdminBundle\Form\Type; 

    use Symfony\Component\Form\AbstractType; 
    use Symfony\Component\Form\FormBuilderInterface; 
    use Symfony\Component\OptionsResolver\OptionsResolverInterface; 
    use JamaLvova\AdminBundle\Form\Type\ExercisePointsFormType; 

    class StartContestFormType extends AbstractType 
    { 
     public function buildForm(FormBuilderInterface $builder, array $options) 
     { 

      $builder->add('startYear', 'hidden') 
        /* 
         some other form elements 
        */ 
        ->add('points', 'collection', array(
         'type' => 'text', 
         'allow_add' => true, 
         'label' => 'Body za jednotlivé úlohy:', 
         'error_bubbling' => false, 
         'options' => array(
          'error_bubbling' => false, 
          'attr' => array("maxlength" => "4", "size" => "4") 
         ) 
         )); 
     } 

     public function setDefaultOptions(OptionsResolverInterface $resolver) 
     { 
      $resolver->setDefaults(array(
       'data_class' => 'JamaLvova\AdminBundle\Form\StartContestForm', 
      )); 
     } 

     public function getName() 
     { 
      return 'startContestForm'; 
     } 
    } 

는 StartContestForm에서 나는 다음과 같이 작성 $ 포인트 속성이 있습니다. 문제가있을 수있는 사람이 있습니까? 또는 나는 무엇인가 놓치고 있냐? 감사합니다 많이 :-) (심포니의 V 2.1.4.)

편집 : 것 같다 그 대신에 '형'의 나는 형태의 모음을 사용하는 경우 ('유형'=> 새로운 PointsFormType()) => '텍스트', 그것은 어떻게 든 예상대로 작동합니다. 특정 필드에 오류를 할당 할 수 있도록 양식 모음을 항상 사용해야한다는 의미입니까?

답변

2

당신은 cascade_validation 속성이 Sf3에 제거 되었기 때문에 cascade_validation' => true

$builder->add('startYear', 'hidden') 
     /* 
      some other form elements 
     */ 
     ->add('points', 'collection', array(
      'type' => 'text', 
      'allow_add' => true, 
      'label' => 'Body za jednotlivé úlohy:', 
      'error_bubbling' => false, 
      'cascade_validation' => true, 
      'attr' => array("maxlength" => "4", "size" => "4") 
     )); 
}