Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2005
    Location
    France
    Posts
    582
    Plugin Contributions
    8

    Default How to set cmd= value in an admin form that uses get

    Site is using ZC 1.5.7c

    I'm doing some modifications on the admin orders.php page and have a form written like this
    Code:
    echo zen_draw_form('split_invoice', FILENAME_ORDERS_INVOICE, '', 'get', 'target="_blank"', true) . "\n";
             echo zen_draw_hidden_field('oID', (int)$oID) . "\n";
    When a submit button is clicked, I was expecting this to open an invoice in a new tab, but instead it's reloading the orders.php page.
    When I inspect element, I see that zen_draw_form is also adding
    Code:
    <input type="hidden" name="cmd" value="orders">
    which explains the reload.

    As a quick and dirty test I added
    Code:
    $_GET['cmd'] = FILENAME_ORDERS_INVOICE;
    after my zen_draw_form and it correctly loads the invoice page.

    What is the CORRECT way of achieving this?

  2. #2
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: How to set cmd= value in an admin form that uses get

    There's actually an html_output.php change that does a bang up job of fixing this, but its not "officially" released so, what I've done is to substitute $_GET['cmd'] for what I want before I draw the form, then after the form I restore $_GET['cmd'] to whatever it was (which may be nothing) so that while the form is being drawn, the value of cmd is set to the value expected rather than depending on the browser to accept the last copy of the hidden input element as the proper assignment.

    Here's that issue reported: $_GET method of admin's zen_draw_form does not support action page other than self · Issue #3922 · zencart/zencart (github.com) with a solution posted within... I was going to try to point to a commit, but the associated one appears to capture more than just this "fix".

    Here is the commit of what I did on one of my plugins: Assign the installer to the cmd parameter for ZC 1.5.7 on · mc12345678/Stock_By_Attributes_Combined@ee541d7 (github.com)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Nov 2005
    Location
    France
    Posts
    582
    Plugin Contributions
    8

    Default Re: How to set cmd= value in an admin form that uses get

    Quote Originally Posted by mc12345678 View Post
    Thanks for the heads up on this actually being a ZC bug. I've followed your example as an interim measure until the full fix is introduced in a later version of Zen Cart. Do you know if it make it into the next release?

  4. #4
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: How to set cmd= value in an admin form that uses get

    Quote Originally Posted by strelitzia View Post
    Thanks for the heads up on this actually being a ZC bug. I've followed your example as an interim measure until the full fix is introduced in a later version of Zen Cart. Do you know if it make it into the next release?
    Its not there yet, but... seeing that it is a confirmed bug, I would expect that something will be done to address it, whether what's posted there as a fix is the final solution or not.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v151 Designing a mod that uses an API to send info offsite
    By delia in forum General Questions
    Replies: 9
    Last Post: 1 Oct 2013, 06:48 PM
  2. How do I set a maximum value for Postal Code in the Admin?
    By thebigkick in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 21 Jun 2012, 01:12 AM
  3. How to set minimum order value?
    By candlesandsoaps in forum Managing Customers and Orders
    Replies: 4
    Last Post: 3 Jun 2010, 03:03 PM
  4. Variables that uses in templates.
    By der Hund in forum Addon Templates
    Replies: 1
    Last Post: 3 Sep 2008, 03:25 PM
  5. How to set option value with a set image as default of an attribute?
    By PaulRiedel in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 16 Aug 2007, 04:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR