Sonata default filter valueSonata admin bundle orderSymfony2 - Give a default filter in a list of elements of Sonata AdminCustomize the Sonata Admin Dashboard - Sonata and Symfony 2Creating custom form type using sonata form type as parentSonata Admin Filter: Invalid parameter number: number of bound variables does not match number of tokenssonata admin custom list field (not from entity)sonata admin add richhtml editor to block contentSonata sort admin list using a aggregate on a child fieldSonata form field - change a field based on the selection of another model fieldSonata admin: mosaic selected by default

Would getting a natural 20 with a penalty still count as a critical hit?

What is the purpose/function of this power inductor in parallel?

How does Monero protect users from inflation bugs if the blockchain can't be audited?

Is there a word for returning to unpreparedness?

Is there a fallacy about "appeal to 'big words'"?

When did Bilbo and Frodo learn that Gandalf was a Maia?

Good way to stop electrolyte tabs from turning into powder?

What's the relationship betweeen MS-DOS and XENIX?

Why does this image of cyclocarbon look like a nonagon?

If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?

What should I do with the stock I own if I anticipate there will be a recession?

Setting up a Mathematical Institute of Refereeing?

Did Michelle Obama have a staff of 23; and Melania have a staff of 4?

Are there any cons in using rounded corners for bar graphs?

What allows us to use imaginary numbers?

Is a USB 3.0 device possible with a four contact USB 2.0 connector?

Attacking the Hydra

pester mode not working for showToastEvent in LWC

What should we do with manuals from the 80s?

What are some tips and tricks for finding the cheapest flight when luggage and other fees are not revealed until far into the booking process?

Minimum population for language survival

A Magic Diamond

May the tower use the runway while an emergency aircraft is inbound?

Physical Interpretation of an Overdamped Pendulum



Sonata default filter value


Sonata admin bundle orderSymfony2 - Give a default filter in a list of elements of Sonata AdminCustomize the Sonata Admin Dashboard - Sonata and Symfony 2Creating custom form type using sonata form type as parentSonata Admin Filter: Invalid parameter number: number of bound variables does not match number of tokenssonata admin custom list field (not from entity)sonata admin add richhtml editor to block contentSonata sort admin list using a aggregate on a child fieldSonata form field - change a field based on the selection of another model fieldSonata admin: mosaic selected by default






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a property in my method configureDatagridFilters() called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.



I have tried:



public function getFilterParameters()

$parameters = parent::getFilterParameters();

$parameters['assignee'] = [
'value' => $this->getUser(),
];

return $parameters;



as well as an array_merge instead. None of them achieved what I'm after, it still just shows me the default/entire list.



I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class and others just a number 3.










share|improve this question






























    0















    I have a property in my method configureDatagridFilters() called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.



    I have tried:



    public function getFilterParameters()

    $parameters = parent::getFilterParameters();

    $parameters['assignee'] = [
    'value' => $this->getUser(),
    ];

    return $parameters;



    as well as an array_merge instead. None of them achieved what I'm after, it still just shows me the default/entire list.



    I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class and others just a number 3.










    share|improve this question


























      0












      0








      0








      I have a property in my method configureDatagridFilters() called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.



      I have tried:



      public function getFilterParameters()

      $parameters = parent::getFilterParameters();

      $parameters['assignee'] = [
      'value' => $this->getUser(),
      ];

      return $parameters;



      as well as an array_merge instead. None of them achieved what I'm after, it still just shows me the default/entire list.



      I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class and others just a number 3.










      share|improve this question














      I have a property in my method configureDatagridFilters() called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.



      I have tried:



      public function getFilterParameters()

      $parameters = parent::getFilterParameters();

      $parameters['assignee'] = [
      'value' => $this->getUser(),
      ];

      return $parameters;



      as well as an array_merge instead. None of them achieved what I'm after, it still just shows me the default/entire list.



      I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class and others just a number 3.







      symfony sonata-admin sonata symfony-sonata






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 12:18









      MylesKMylesK

      21512 bronze badges




      21512 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0














          So I figured out how to set the filter by default to the current user.



          My filter is an EntityType::class with the class of User::class. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId().



          So the full method would be:



          public function getFilterParameters()

          $parameters = parent::getFilterParameters();

          $parameters['assignee'] = [
          'value' => $this->getUser()->getId(),
          ];

          return $parameters;






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377028%2fsonata-default-filter-value%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            So I figured out how to set the filter by default to the current user.



            My filter is an EntityType::class with the class of User::class. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId().



            So the full method would be:



            public function getFilterParameters()

            $parameters = parent::getFilterParameters();

            $parameters['assignee'] = [
            'value' => $this->getUser()->getId(),
            ];

            return $parameters;






            share|improve this answer





























              0














              So I figured out how to set the filter by default to the current user.



              My filter is an EntityType::class with the class of User::class. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId().



              So the full method would be:



              public function getFilterParameters()

              $parameters = parent::getFilterParameters();

              $parameters['assignee'] = [
              'value' => $this->getUser()->getId(),
              ];

              return $parameters;






              share|improve this answer



























                0












                0








                0







                So I figured out how to set the filter by default to the current user.



                My filter is an EntityType::class with the class of User::class. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId().



                So the full method would be:



                public function getFilterParameters()

                $parameters = parent::getFilterParameters();

                $parameters['assignee'] = [
                'value' => $this->getUser()->getId(),
                ];

                return $parameters;






                share|improve this answer













                So I figured out how to set the filter by default to the current user.



                My filter is an EntityType::class with the class of User::class. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId().



                So the full method would be:



                public function getFilterParameters()

                $parameters = parent::getFilterParameters();

                $parameters['assignee'] = [
                'value' => $this->getUser()->getId(),
                ];

                return $parameters;







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 15:27









                MylesKMylesK

                21512 bronze badges




                21512 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377028%2fsonata-default-filter-value%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript