symfony2에서 콜백을 사용하여 양식을 검증하려고하지만 콜백이 호출되지 않습니다. 콜백이있는 클래스는 컬렉션을 통해 기본 폼에서 호출됩니다. 여기 Symfony2 - 콜렉션 유효성 검사기
내 코드는
...Main 클래스 :
class InscriptionType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('inscriptionReponses','collection',array('label'=>false,
'type'=>new InscriptionReponseType(),
'error_bubbling'=>false,
'by_reference'=>false))
;
}
}
InscriptionReponse 클래스 : 내가 잘못 이해하지
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\ExecutionContextInterface;
/**
* InscriptionReponse
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="Ptolemee\ColloqueBundle\Entity\InscriptionReponseRepository")
* @Assert\Callback(methods={"formValidation"})
*/
class InscriptionReponse
{
/* ... some code ... */
public function formValidation(ExecutionContextInterface $context)
{
die('not dying ?');
}
}
... 어떤 도움은 매우 될 것 고맙습니다. tahnks.
니콜라스.
http://symfony.com/doc/current/reference/constraints/Callback.html
대신
/**
* @Assert\Callback(methods={"formValidation"})
*/
class InscriptionReponse
{
의 당신은 함수 자체
class InscriptionReponse
{
/**
* @Assert\Callback
*/
public function formValidation(ExecutionContextInterface $context)
{
die('not dying ?');
}
방법 당신이 위의 주석을 이동해야합니다 : 문서에 기록 된 사항에
안녕하세요, 요 답변 주셔서 감사합니다 ... 실제로 2.4를 사용하므로 주석을 mvoved. 하지만 여전히 작동하지 않습니다 ... 결코 콜백을 전달하지 마십시오 ... – nikophil
양식 옵션을 설정해보십시오 : 'error_bubbling'=> true –
어느 쪽이든 true 또는 false로 작동하지 않습니다 .... :/: – nikophil