dpwjx32578146 2014-02-13 19:10
浏览 41
已采纳

Symfony2 - 使用$ _GET进行表单处理

It's a simply problem but, I have question about Form process (isValid() & GetData()) with $_GET request not a $_POST request.

$form->isValid() // return false everytime !
$form->getData() // return NULL everytime too

So I deduced that this was the method $_GET which prevents normal process of form validation. Someone has already had this problem ??

More infos : I've a class form name LargeSearchType.php without entity relation. Just a search engine form with many select,checkbox... My controller use Symfony2 standard (documentation) process form. (http://symfony.com/fr/doc/current/book/forms.html#gerer-la-soumission-des-formulaires)

  • 写回答

1条回答 默认 最新

  • duanjizi9443 2014-02-13 19:15
    关注

    You should set the method of the form to GET:

    $form = $this->createFormBuilder($task)
                 ->setMethod('GET')
    

    http://symfony.com/doc/current/book/forms.html#changing-the-action-and-method-of-a-form

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?