Wednesday, April 2, 2014

Symfony forms disable csrf protection

Şöyle iki şekilde yapılabilir. İlki formu olustururken, ikincisi de kökten çözüm EntityFormType içine yazarak. İkincisini yaparsanız ilgili tüm form kullanımlarında csrf olayını kapatmış oluyorsunuz.
<?php
$form = $this->createFormBuilder($posts, array(
'csrf_protection' => false
))->add(...)
;
<?php
/**
.....
*/
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$resolver->setDefaults(array(
'data_class' => 'Ojstr\BlogBundle\Entity\Post',
'csrf_protection' => false
));
}
view raw sf-formtype.php hosted with ❤ by GitHub

No comments: