Magento 2 Set $_POST to an empty Array()getFormAction() returns empty stringMagento does not pass empty varible in POST datasaveAction stores empty objectMagento 2 simple form submitmagento 2 get empty post array in version 2.0.5Array to string conversion in Magento 2Magento 2 | Get Post ParamsMagento 2 ui form multiselect field not checked not in $_POSTDirect use of $_FILES Superglobal detected. In magento 2Magento 1.9.2 - getRequest()->getParams returning with empty array

Why didn't Balak request Bilam to bless his own people?

Do gauntlets count as armor?

What is the difference between uniform velocity and constant velocity?

How to tell readers that I know my story is factually incorrect?

How can electronics on board JWST survive the low operating temperature while it's difficult to survive lunar nights?

Why should fork() have been designed to return a file descriptor?

Why didn't NASA launch communications relay satellites for the Apollo missions?

What does a Nintendo Game Boy do when turned on without a game cartridge inserted?

Improving an O(N^2) function (all entities iterating over all other entities)

Satellite in orbit in front of and behind the Moon

Can two waves interfere head on?

ISCSI, multiple initiaros for the same lun

When will the last unambiguous evidence of mankind disappear?

Killing a star safely

What does "play in traffic" mean?

Conditional statement in a function for PS1 are not re-evalutated

Why can't a country print its own money to spend it only abroad?

Why does Plot only sometimes use different colors for each curve

What is this light passenger prop airplane which crash landed in East Kalimantan, Borneo in 1983?

What is the origin of "Wonder begets wisdom?"

She told me that she HAS / HAD a gun

Redirection operator, standard input and command parameters

You have no, but can try for yes

How much did all the space agencies spent on rockets launching and space exploration? What are the benefits for me and you?



Magento 2 Set $_POST to an empty Array()


getFormAction() returns empty stringMagento does not pass empty varible in POST datasaveAction stores empty objectMagento 2 simple form submitmagento 2 get empty post array in version 2.0.5Array to string conversion in Magento 2Magento 2 | Get Post ParamsMagento 2 ui form multiselect field not checked not in $_POSTDirect use of $_FILES Superglobal detected. In magento 2Magento 1.9.2 - getRequest()->getParams returning with empty array






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








3















I can't seem to find a way to set $_POST to an empty array.



I have a form in phtml action to self I can get $_POST values the following ways:



$this->getRequest()->getPostValue('form_key');

$this->getRequest()->getParam('form_key');


The Above will give Array ( [form_key] => FThdknnc_347djcncKey_)



Now I've tried to reset by doing:



$this->getRequest()->setPostValue('form_key');


But it gives me:



Array ([form_key] =>)


That ain't right browser still popping up saying that it will resend data from form: It should return Array () But the form_key key is still in the $_POST Array. one can do in php:



$_POST = Array(); and that would be enough but it doesn't work with magento.



Anyone any idea?










share|improve this question




























    3















    I can't seem to find a way to set $_POST to an empty array.



    I have a form in phtml action to self I can get $_POST values the following ways:



    $this->getRequest()->getPostValue('form_key');

    $this->getRequest()->getParam('form_key');


    The Above will give Array ( [form_key] => FThdknnc_347djcncKey_)



    Now I've tried to reset by doing:



    $this->getRequest()->setPostValue('form_key');


    But it gives me:



    Array ([form_key] =>)


    That ain't right browser still popping up saying that it will resend data from form: It should return Array () But the form_key key is still in the $_POST Array. one can do in php:



    $_POST = Array(); and that would be enough but it doesn't work with magento.



    Anyone any idea?










    share|improve this question
























      3












      3








      3








      I can't seem to find a way to set $_POST to an empty array.



      I have a form in phtml action to self I can get $_POST values the following ways:



      $this->getRequest()->getPostValue('form_key');

      $this->getRequest()->getParam('form_key');


      The Above will give Array ( [form_key] => FThdknnc_347djcncKey_)



      Now I've tried to reset by doing:



      $this->getRequest()->setPostValue('form_key');


      But it gives me:



      Array ([form_key] =>)


      That ain't right browser still popping up saying that it will resend data from form: It should return Array () But the form_key key is still in the $_POST Array. one can do in php:



      $_POST = Array(); and that would be enough but it doesn't work with magento.



      Anyone any idea?










      share|improve this question














      I can't seem to find a way to set $_POST to an empty array.



      I have a form in phtml action to self I can get $_POST values the following ways:



      $this->getRequest()->getPostValue('form_key');

      $this->getRequest()->getParam('form_key');


      The Above will give Array ( [form_key] => FThdknnc_347djcncKey_)



      Now I've tried to reset by doing:



      $this->getRequest()->setPostValue('form_key');


      But it gives me:



      Array ([form_key] =>)


      That ain't right browser still popping up saying that it will resend data from form: It should return Array () But the form_key key is still in the $_POST Array. one can do in php:



      $_POST = Array(); and that would be enough but it doesn't work with magento.



      Anyone any idea?







      forms magento2.2.2 post-data






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 12 at 11:11









      Juliano VargasJuliano Vargas

      7376 silver badges26 bronze badges




      7376 silver badges26 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          1














          Try this:



          /** @var ZendStdlibParametersInterface $postParameters */
          $postParameters = $this->getRequest()->getPost();
          $postParameters->fromArray([]);


          Use getQuery method to clean GET parameters.






          share|improve this answer






























            0














            You can try like this,



            $formKey = $this->getRequest()->getPostValue('form_key');

            unset($formKey);


            than after you can try to set again



            $this->getRequest()->setPostValue('form_key','your_value');


            Hope it helps.






            share|improve this answer

























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "479"
              ;
              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: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              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%2fmagento.stackexchange.com%2fquestions%2f281879%2fmagento-2-set-post-to-an-empty-array%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              Try this:



              /** @var ZendStdlibParametersInterface $postParameters */
              $postParameters = $this->getRequest()->getPost();
              $postParameters->fromArray([]);


              Use getQuery method to clean GET parameters.






              share|improve this answer



























                1














                Try this:



                /** @var ZendStdlibParametersInterface $postParameters */
                $postParameters = $this->getRequest()->getPost();
                $postParameters->fromArray([]);


                Use getQuery method to clean GET parameters.






                share|improve this answer

























                  1












                  1








                  1







                  Try this:



                  /** @var ZendStdlibParametersInterface $postParameters */
                  $postParameters = $this->getRequest()->getPost();
                  $postParameters->fromArray([]);


                  Use getQuery method to clean GET parameters.






                  share|improve this answer













                  Try this:



                  /** @var ZendStdlibParametersInterface $postParameters */
                  $postParameters = $this->getRequest()->getPost();
                  $postParameters->fromArray([]);


                  Use getQuery method to clean GET parameters.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 12 at 12:11









                  Evgeny LevinskyEvgeny Levinsky

                  9251 gold badge4 silver badges11 bronze badges




                  9251 gold badge4 silver badges11 bronze badges























                      0














                      You can try like this,



                      $formKey = $this->getRequest()->getPostValue('form_key');

                      unset($formKey);


                      than after you can try to set again



                      $this->getRequest()->setPostValue('form_key','your_value');


                      Hope it helps.






                      share|improve this answer



























                        0














                        You can try like this,



                        $formKey = $this->getRequest()->getPostValue('form_key');

                        unset($formKey);


                        than after you can try to set again



                        $this->getRequest()->setPostValue('form_key','your_value');


                        Hope it helps.






                        share|improve this answer

























                          0












                          0








                          0







                          You can try like this,



                          $formKey = $this->getRequest()->getPostValue('form_key');

                          unset($formKey);


                          than after you can try to set again



                          $this->getRequest()->setPostValue('form_key','your_value');


                          Hope it helps.






                          share|improve this answer













                          You can try like this,



                          $formKey = $this->getRequest()->getPostValue('form_key');

                          unset($formKey);


                          than after you can try to set again



                          $this->getRequest()->setPostValue('form_key','your_value');


                          Hope it helps.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 12 at 12:22









                          Mohit RaneMohit Rane

                          77416 bronze badges




                          77416 bronze badges



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • 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%2fmagento.stackexchange.com%2fquestions%2f281879%2fmagento-2-set-post-to-an-empty-array%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

                              Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                              Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                              Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form