php - default Filtering Sonata admin list without a Filter filed -


i'm using sonata mongodb admin bundle , need filter default list data without filter field.

i have 'tenant_id' attribute in model , want show models if tenant_id equal id of connected user.

any 1 can ?

you can override createquery function of admin class described here, https://sonata-project.org/bundles/admin/master/doc/reference/action_list.html#customizing-the-query-used-to-generate-the-list

public function createquery($context = 'list') {     $query = parent::createquery($context);     $query->field('tenant_id')->equals("your user id");     return $query; } 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -