Skip to content

FIX: allow to use array as field values in scope filters #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2016

Conversation

ksn135
Copy link
Contributor

@ksn135 ksn135 commented May 11, 2016

In my case I need to use several states (array) in filter to achieve required functionality (as it always works for me before in previous versions).
Without this fix cache:clear throws exception >> Skip warmup An exception has been thrown during the rendering of a template ("Notice: Array to string conversion") in "../CommonAdmin/ListAction/scopes.php.twig".
Example:

            scopes:
                group_1: 
                    "Все": 
                        default: true
                        filters: 
                            -      notArchive
                    "Ждут согласования": 
                        filters: 
                            state: [draft, declined, checked]
                    "У Куратора": 
                        filters: 
                            state: reviewed
                    "В Бухгалтерии": 
                        filters: 
                            state: accounted
                    "В ФинСлужбе": 
                        filters: 
                            state: appointed
                    "В Казначействе": 
                        filters: 
                            state: treasured
                    "Ожидают оплаты": 
                        filters: 
                            state: suspended
                            1:     notToday
                    "Оплаты на сегодня": 
                        filters: 
                            state: suspended
                            1:     today
                    "В Реестре на сегодня": 
                        filters: 
                            state: approved
                    "В 1С": 
                        filters: 
                            state: [assigned, uploaded, sended, cashed]
                    "Оплата не возможна": 
                        filters: 
                            state: canceled
                    "Оплачено": 
                        filters: 
                            state: payed
                    "Архив": 
                        filters: 
                            state: archive

                group_2: 
                    "Не важно": 
                        default: true
                        filters: ~
                    "Без договора": 
                        filters: 
                            bargainSendTo1CState:  none
                    "На создании": 
                        filters: 
                            bargainSendTo1CState:  draft
                    "На согласовании": 
                        filters: 
                            bargainSendTo1CState:  concordance
                    "Согласован": 
                        filters: 
                            bargainSendTo1CState:  done

@ksn135
Copy link
Contributor Author

ksn135 commented May 14, 2016

Any chances to apply this fix on this weekend ?

@sescandell
Copy link
Member

@ksn135 is this fix working on your project?

@ksn135
Copy link
Contributor Author

ksn135 commented May 16, 2016

It's allow me use array as value.
Also you need to modify filter function:

    protected function filterState($queryFilter, $value)
    {
        $queryFilter->addDefaultFilter('state', $value);
    }

WBR, KSN.

On Mon, May 16, 2016 at 10:34 AM, Stéphane [email protected] wrote:

@ksn135 https://github.com/ksn135 is this fix working on your project?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#283 (comment)

@calvera
Copy link
Contributor

calvera commented May 16, 2016

hi,

i had a similar problem:
https://github.com/calvera/GeneratorBundle/blob/fixes/Resources/templates/CommonAdmin/ListAction/scopes.php.twig#L109

                           $filters['{{ filter }}'] = {%- if filterParams is not iterable -%}'{{ filterParams }}'{%- else -%}array({% for param in filterParams %}'{{ param }}'{% if not loop.last %},{% endif %}{% endfor %}){%- endif -%};

@sescandell sescandell merged commit 3ce13c7 into symfony2admingenerator:master May 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants