symfony2admingenerator / AdmingeneratorGeneratorBundle

(old-legacy) Admingenerator for Symfony2, parse generator.yml files to build classes
http://symfony2admingenerator.org/
MIT License
360 stars 125 forks source link

use form values instead of request params in filtersAction #671

Open soeren-helbig opened 10 years ago

soeren-helbig commented 10 years ago

I have several DataTransformers appended to form types. Some of them i need inside the filter form. After a little code review, i noticed the form values are not used for setting filters.

//templates\CommonAdmin\ListAction\filters.php.twig
if ($this->getRequest()->getMethod() == "GET") {
    $filters = $this->getRequest()->query->all();
}

but some lines above there i read this:

//templates\CommonAdmin\ListAction\filters.php.twig
if ($this->getRequest()->getMethod() == "POST") {
    $form = $this->getFilterForm();
    $form->bind($this->get('request'));

    if ($form->isValid()) {
        $filters = $form->getClientData();
    }
}

please, can you help me understand this? in my opinion, if form values are valid there is nothing against using them instead of query parameters, isn't it?!

sescandell commented 10 years ago

Hi @soeren-helbig

Query parameters are used for scope.

If you use "normal" case for filters, you should be in a post request and so FilterForm should be submitted and so your DataTransformers should be used.

Or maybe I missed something in what you wanted to point out?