简体   繁体   中英

Advanced filters disappearing after filtering in Sonata Admin

I've installed Sonata Admin Bundle in my Symfony2 project. Here is my composer.json's require:

    "require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.7.*",
    "doctrine/orm": "~2.2,>=2.2.3,<2.5",
    "doctrine/dbal": "<2.5",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~4.0",
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "doctrine/doctrine-migrations-bundle": "^1.0",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "cunningsoft/chat-bundle": "^0.4.0",
    "knplabs/knp-time-bundle": "^1.3",
    "knplabs/knp-paginator-bundle": "^2.4",
    "knplabs/knp-menu-bundle": "~2",
    "twig/extensions": "^1.3",

    "sonata-project/core-bundle": "^2.3",
    "sonata-project/block-bundle": "^2.3.8",
    "sonata-project/admin-bundle": "dev-master",
    "sonata-project/doctrine-orm-admin-bundle": "^2.3"
},

I'm using the dev-master version, but this issue seems to appear for the 2.3 version, too.

I have some posts made by users, and whenever I want to use advanced filters to filter something, the advanced filters disappear after filtering, but if I recheck the 'advanced filters' link, they appear with the value inside.

This happens in both dev-master and 2.3 version, and it happens on all entities, not just this one.

I've checked the Sonata Sandbox demo and this doesn't happen there. How come? Is it a setting that enables this? Or is it a certain version? How to make the advanced filters stay visible after filtering?

Before filtering, I add a filter by 'Details'

在此处输入图片说明

After filtering, the advanced filter box disappears:

在此处输入图片说明

But if I press 'Advanced filters' link again, it will appear and still have the 'does not contain' option selected.

It seems this is actually their intended behaviour ???

/* Advanced filters */
if (jQuery('.advanced-filter :input:visible', subject).filter(function () {     return jQuery(this).val() }).length === 0) {
    jQuery('.advanced-filter').hide();
};

I have no clue why they are doing this ...

It occurs in vendor/sonata-project/admin-bundle/Resources/public/Admin.js

If you where to copy this file into you own bundle (wich has SonataAdminBundle as parent Bundle), and comment the vendor/sonata-project/admin-bundle/Resources/public line, you should get the behavour you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM