Magento 1.9 : sales_flat_order and sales_flat_order_grid tables are not updatingObserver on sales_order_invoice_save_afterMagento 1.9 cart not updatingMagento get Seller SKU In invoiceMagento Add value in custom column of sales_flat_order tablesales_flat_order_grid VS sales_flat_order?Magento model not fetching dataSQLSTATE[HY000] : General error: 2013 Lost connection to MySQL server during query in MagentoMagento 1.9 Where is original price saved in order tables?Order status out of sync between sales_flat_order and sales_flat_order_gridbackend sales order view filter are not working in magento 2?Orders are not inserted in the sales_flat_order and sales_flat_invoice tables Magento 1.9

How can I repair scratches on a painted French door?

Why is the Turkish president's surname spelt in Russian as Эрдоган, with г?

Alphabet completion rate

Counting occurrence of words in table is slow

Calculating the partial sum of a expl3 sequence

In the Marvel universe, can a human have a baby with any non-human?

Fitting a mixture of two normal distributions for a data set?

Was touching your nose a greeting in second millenium Mesopotamia?

First-year PhD giving a talk among well-established researchers in the field

Links to webpages in books

Architecture of networked game engine

What would Earth look like at night in medieval times?

Pull-up sequence accumulator counter

Are Finite Automata Turing Complete?

Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback

A player is constantly pestering me about rules, what do I do as a DM?

Why is C++ initial allocation so much larger than C's?

Singing along to guitar chords (harmony)

Do equal angles necessarily mean a polygon is regular?

Analog is Obtuse!

Find smallest index that is identical to the value in an array

Should I include salary information on my CV?

How can I convince my reader that I will not use a certain trope?

How often can a PC check with passive perception during a combat turn?



Magento 1.9 : sales_flat_order and sales_flat_order_grid tables are not updating


Observer on sales_order_invoice_save_afterMagento 1.9 cart not updatingMagento get Seller SKU In invoiceMagento Add value in custom column of sales_flat_order tablesales_flat_order_grid VS sales_flat_order?Magento model not fetching dataSQLSTATE[HY000] : General error: 2013 Lost connection to MySQL server during query in MagentoMagento 1.9 Where is original price saved in order tables?Order status out of sync between sales_flat_order and sales_flat_order_gridbackend sales order view filter are not working in magento 2?Orders are not inserted in the sales_flat_order and sales_flat_invoice tables Magento 1.9






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








1















I used many update methods for update values in sales_flat_order and sales_flat_order_grid tables, but no method didn't work.



I don't know why the update is not done.



Method 1:-




$coreResource = Mage::getSingleton('core/resource');
$write = $coreResource->getConnection('core_write');
$_field_flat_order =array();
$_field_flat_order['grand_total'] = $order_gt;
$_field_flat_order['base_grand_total'] = $order_gt;
$_field_flat_order['discount_amount'] = $order_discount;
$_field_flat_order['base_discount_amount'] = $order_discount;
$_field_flat_order['discount_description'] = "1%";
$write->update($coreResource->getTableName('sales_flat_order'),$_field_flat_order,array('entity_id = ?' => $order_id,));


Method 2:-




$order_data=Mage::getModel('sales/order')->loadByIncrementId($increment_id);
$order_data->setGrandTotal($order_gt);
$order_data->setBaseGrandTotal($order_gt);
$order_data->setBaseDiscountAmount($order_discount);
$order_data->setDiscountAmount($order_discount);
$order_data->setDiscountDescription("1%");
$order_data->save();


Method 3 :-




$sql_order = "UPDATE sales_flat_order SET grand_total='".$order_gt."',base_grand_total='".$order_gt."',discount_amount='".$order_discount."',base_discount_amount='".$order_discount."',discount_description='1%' WHERE entity_id ='".$order_id."'";
$write->query($sql_order);


No method didn't work, but all other tables are updating perfectly.



Anyone know the reason.?










share|improve this question






























    1















    I used many update methods for update values in sales_flat_order and sales_flat_order_grid tables, but no method didn't work.



    I don't know why the update is not done.



    Method 1:-




    $coreResource = Mage::getSingleton('core/resource');
    $write = $coreResource->getConnection('core_write');
    $_field_flat_order =array();
    $_field_flat_order['grand_total'] = $order_gt;
    $_field_flat_order['base_grand_total'] = $order_gt;
    $_field_flat_order['discount_amount'] = $order_discount;
    $_field_flat_order['base_discount_amount'] = $order_discount;
    $_field_flat_order['discount_description'] = "1%";
    $write->update($coreResource->getTableName('sales_flat_order'),$_field_flat_order,array('entity_id = ?' => $order_id,));


    Method 2:-




    $order_data=Mage::getModel('sales/order')->loadByIncrementId($increment_id);
    $order_data->setGrandTotal($order_gt);
    $order_data->setBaseGrandTotal($order_gt);
    $order_data->setBaseDiscountAmount($order_discount);
    $order_data->setDiscountAmount($order_discount);
    $order_data->setDiscountDescription("1%");
    $order_data->save();


    Method 3 :-




    $sql_order = "UPDATE sales_flat_order SET grand_total='".$order_gt."',base_grand_total='".$order_gt."',discount_amount='".$order_discount."',base_discount_amount='".$order_discount."',discount_description='1%' WHERE entity_id ='".$order_id."'";
    $write->query($sql_order);


    No method didn't work, but all other tables are updating perfectly.



    Anyone know the reason.?










    share|improve this question


























      1












      1








      1








      I used many update methods for update values in sales_flat_order and sales_flat_order_grid tables, but no method didn't work.



      I don't know why the update is not done.



      Method 1:-




      $coreResource = Mage::getSingleton('core/resource');
      $write = $coreResource->getConnection('core_write');
      $_field_flat_order =array();
      $_field_flat_order['grand_total'] = $order_gt;
      $_field_flat_order['base_grand_total'] = $order_gt;
      $_field_flat_order['discount_amount'] = $order_discount;
      $_field_flat_order['base_discount_amount'] = $order_discount;
      $_field_flat_order['discount_description'] = "1%";
      $write->update($coreResource->getTableName('sales_flat_order'),$_field_flat_order,array('entity_id = ?' => $order_id,));


      Method 2:-




      $order_data=Mage::getModel('sales/order')->loadByIncrementId($increment_id);
      $order_data->setGrandTotal($order_gt);
      $order_data->setBaseGrandTotal($order_gt);
      $order_data->setBaseDiscountAmount($order_discount);
      $order_data->setDiscountAmount($order_discount);
      $order_data->setDiscountDescription("1%");
      $order_data->save();


      Method 3 :-




      $sql_order = "UPDATE sales_flat_order SET grand_total='".$order_gt."',base_grand_total='".$order_gt."',discount_amount='".$order_discount."',base_discount_amount='".$order_discount."',discount_description='1%' WHERE entity_id ='".$order_id."'";
      $write->query($sql_order);


      No method didn't work, but all other tables are updating perfectly.



      Anyone know the reason.?










      share|improve this question
















      I used many update methods for update values in sales_flat_order and sales_flat_order_grid tables, but no method didn't work.



      I don't know why the update is not done.



      Method 1:-




      $coreResource = Mage::getSingleton('core/resource');
      $write = $coreResource->getConnection('core_write');
      $_field_flat_order =array();
      $_field_flat_order['grand_total'] = $order_gt;
      $_field_flat_order['base_grand_total'] = $order_gt;
      $_field_flat_order['discount_amount'] = $order_discount;
      $_field_flat_order['base_discount_amount'] = $order_discount;
      $_field_flat_order['discount_description'] = "1%";
      $write->update($coreResource->getTableName('sales_flat_order'),$_field_flat_order,array('entity_id = ?' => $order_id,));


      Method 2:-




      $order_data=Mage::getModel('sales/order')->loadByIncrementId($increment_id);
      $order_data->setGrandTotal($order_gt);
      $order_data->setBaseGrandTotal($order_gt);
      $order_data->setBaseDiscountAmount($order_discount);
      $order_data->setDiscountAmount($order_discount);
      $order_data->setDiscountDescription("1%");
      $order_data->save();


      Method 3 :-




      $sql_order = "UPDATE sales_flat_order SET grand_total='".$order_gt."',base_grand_total='".$order_gt."',discount_amount='".$order_discount."',base_discount_amount='".$order_discount."',discount_description='1%' WHERE entity_id ='".$order_id."'";
      $write->query($sql_order);


      No method didn't work, but all other tables are updating perfectly.



      Anyone know the reason.?







      magento-1.9 sales-order sales-order-grid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 17 at 5:17









      Aasim Goriya

      3,2371 gold badge11 silver badges43 bronze badges




      3,2371 gold badge11 silver badges43 bronze badges










      asked Feb 14 '18 at 12:56









      Nagaraj JuroNagaraj Juro

      2981 silver badge15 bronze badges




      2981 silver badge15 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          0














          Try:



          <?php $write = Mage::getSingleton('core/resource')->getConnection('core_write'); ?>


          And:



          <?php
          $write->query("UPDATE sales_flat_order SET grand_total = '$order_gt', base_grand_total = '$order_gt', discount_amount = '$order_discount', base_discount_amount = '$order_discount', discount_description ='1%' WHERE entity_id = '$order_id'");
          ?>





          share|improve this answer

























          • This is also not working @Marcel,I think there is a connection problem. But thank you.

            – Nagaraj Juro
            Feb 15 '18 at 9:19











          • Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?

            – Marcel
            Feb 15 '18 at 10:50












          • I am using update query in observer(sales_order_invoice_save_after) file.

            – Nagaraj Juro
            Feb 15 '18 at 11:25











          • If execute query directly in phpmyadmin,update is working.

            – Nagaraj Juro
            Feb 15 '18 at 11:26











          • Maybe this could help you: magento.stackexchange.com/questions/60288/…

            – Marcel
            Feb 16 '18 at 13:26


















          0














          Having in mind that "While creating invoice to particular order, We can't update sales order tables for that particular order.", you can update that order getting it from the observer Example:



          config.xml
          ...



          <events>
          <sales_order_invoice_save_after>
          <observers>
          <unique_identifier>
          <type>singleton</type>
          <class>Module_SalesOrder_Model_Observer</class>
          <method>updateDeliveryDate</method>
          </unique_identifier>
          </observers>
          </sales_order_invoice_save_after>
          </events>


          ...



          Observer



          class Module_SalesOrder_Model_Observer

          public function updateDeliveryDate(Varien_Event_Observer $observer)
          $_event = $observer->getEvent();
          $_invoice = $_event->getInvoice();
          $_order = $_invoice->getOrder();

          $_order->setDeliveryAt('2018-03-26 00:00:00');
          $_order->save();







          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%2f213499%2fmagento-1-9-sales-flat-order-and-sales-flat-order-grid-tables-are-not-updating%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









            0














            Try:



            <?php $write = Mage::getSingleton('core/resource')->getConnection('core_write'); ?>


            And:



            <?php
            $write->query("UPDATE sales_flat_order SET grand_total = '$order_gt', base_grand_total = '$order_gt', discount_amount = '$order_discount', base_discount_amount = '$order_discount', discount_description ='1%' WHERE entity_id = '$order_id'");
            ?>





            share|improve this answer

























            • This is also not working @Marcel,I think there is a connection problem. But thank you.

              – Nagaraj Juro
              Feb 15 '18 at 9:19











            • Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?

              – Marcel
              Feb 15 '18 at 10:50












            • I am using update query in observer(sales_order_invoice_save_after) file.

              – Nagaraj Juro
              Feb 15 '18 at 11:25











            • If execute query directly in phpmyadmin,update is working.

              – Nagaraj Juro
              Feb 15 '18 at 11:26











            • Maybe this could help you: magento.stackexchange.com/questions/60288/…

              – Marcel
              Feb 16 '18 at 13:26















            0














            Try:



            <?php $write = Mage::getSingleton('core/resource')->getConnection('core_write'); ?>


            And:



            <?php
            $write->query("UPDATE sales_flat_order SET grand_total = '$order_gt', base_grand_total = '$order_gt', discount_amount = '$order_discount', base_discount_amount = '$order_discount', discount_description ='1%' WHERE entity_id = '$order_id'");
            ?>





            share|improve this answer

























            • This is also not working @Marcel,I think there is a connection problem. But thank you.

              – Nagaraj Juro
              Feb 15 '18 at 9:19











            • Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?

              – Marcel
              Feb 15 '18 at 10:50












            • I am using update query in observer(sales_order_invoice_save_after) file.

              – Nagaraj Juro
              Feb 15 '18 at 11:25











            • If execute query directly in phpmyadmin,update is working.

              – Nagaraj Juro
              Feb 15 '18 at 11:26











            • Maybe this could help you: magento.stackexchange.com/questions/60288/…

              – Marcel
              Feb 16 '18 at 13:26













            0












            0








            0







            Try:



            <?php $write = Mage::getSingleton('core/resource')->getConnection('core_write'); ?>


            And:



            <?php
            $write->query("UPDATE sales_flat_order SET grand_total = '$order_gt', base_grand_total = '$order_gt', discount_amount = '$order_discount', base_discount_amount = '$order_discount', discount_description ='1%' WHERE entity_id = '$order_id'");
            ?>





            share|improve this answer















            Try:



            <?php $write = Mage::getSingleton('core/resource')->getConnection('core_write'); ?>


            And:



            <?php
            $write->query("UPDATE sales_flat_order SET grand_total = '$order_gt', base_grand_total = '$order_gt', discount_amount = '$order_discount', base_discount_amount = '$order_discount', discount_description ='1%' WHERE entity_id = '$order_id'");
            ?>






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 15 '18 at 7:21

























            answered Feb 14 '18 at 14:33









            MarcelMarcel

            11012 bronze badges




            11012 bronze badges












            • This is also not working @Marcel,I think there is a connection problem. But thank you.

              – Nagaraj Juro
              Feb 15 '18 at 9:19











            • Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?

              – Marcel
              Feb 15 '18 at 10:50












            • I am using update query in observer(sales_order_invoice_save_after) file.

              – Nagaraj Juro
              Feb 15 '18 at 11:25











            • If execute query directly in phpmyadmin,update is working.

              – Nagaraj Juro
              Feb 15 '18 at 11:26











            • Maybe this could help you: magento.stackexchange.com/questions/60288/…

              – Marcel
              Feb 16 '18 at 13:26

















            • This is also not working @Marcel,I think there is a connection problem. But thank you.

              – Nagaraj Juro
              Feb 15 '18 at 9:19











            • Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?

              – Marcel
              Feb 15 '18 at 10:50












            • I am using update query in observer(sales_order_invoice_save_after) file.

              – Nagaraj Juro
              Feb 15 '18 at 11:25











            • If execute query directly in phpmyadmin,update is working.

              – Nagaraj Juro
              Feb 15 '18 at 11:26











            • Maybe this could help you: magento.stackexchange.com/questions/60288/…

              – Marcel
              Feb 16 '18 at 13:26
















            This is also not working @Marcel,I think there is a connection problem. But thank you.

            – Nagaraj Juro
            Feb 15 '18 at 9:19





            This is also not working @Marcel,I think there is a connection problem. But thank you.

            – Nagaraj Juro
            Feb 15 '18 at 9:19













            Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?

            – Marcel
            Feb 15 '18 at 10:50






            Connection problem to Database? In which file you placed the Code? Have you tried the Update... direct in the database (with changed variables in orginal values) to test the query?

            – Marcel
            Feb 15 '18 at 10:50














            I am using update query in observer(sales_order_invoice_save_after) file.

            – Nagaraj Juro
            Feb 15 '18 at 11:25





            I am using update query in observer(sales_order_invoice_save_after) file.

            – Nagaraj Juro
            Feb 15 '18 at 11:25













            If execute query directly in phpmyadmin,update is working.

            – Nagaraj Juro
            Feb 15 '18 at 11:26





            If execute query directly in phpmyadmin,update is working.

            – Nagaraj Juro
            Feb 15 '18 at 11:26













            Maybe this could help you: magento.stackexchange.com/questions/60288/…

            – Marcel
            Feb 16 '18 at 13:26





            Maybe this could help you: magento.stackexchange.com/questions/60288/…

            – Marcel
            Feb 16 '18 at 13:26













            0














            Having in mind that "While creating invoice to particular order, We can't update sales order tables for that particular order.", you can update that order getting it from the observer Example:



            config.xml
            ...



            <events>
            <sales_order_invoice_save_after>
            <observers>
            <unique_identifier>
            <type>singleton</type>
            <class>Module_SalesOrder_Model_Observer</class>
            <method>updateDeliveryDate</method>
            </unique_identifier>
            </observers>
            </sales_order_invoice_save_after>
            </events>


            ...



            Observer



            class Module_SalesOrder_Model_Observer

            public function updateDeliveryDate(Varien_Event_Observer $observer)
            $_event = $observer->getEvent();
            $_invoice = $_event->getInvoice();
            $_order = $_invoice->getOrder();

            $_order->setDeliveryAt('2018-03-26 00:00:00');
            $_order->save();







            share|improve this answer



























              0














              Having in mind that "While creating invoice to particular order, We can't update sales order tables for that particular order.", you can update that order getting it from the observer Example:



              config.xml
              ...



              <events>
              <sales_order_invoice_save_after>
              <observers>
              <unique_identifier>
              <type>singleton</type>
              <class>Module_SalesOrder_Model_Observer</class>
              <method>updateDeliveryDate</method>
              </unique_identifier>
              </observers>
              </sales_order_invoice_save_after>
              </events>


              ...



              Observer



              class Module_SalesOrder_Model_Observer

              public function updateDeliveryDate(Varien_Event_Observer $observer)
              $_event = $observer->getEvent();
              $_invoice = $_event->getInvoice();
              $_order = $_invoice->getOrder();

              $_order->setDeliveryAt('2018-03-26 00:00:00');
              $_order->save();







              share|improve this answer

























                0












                0








                0







                Having in mind that "While creating invoice to particular order, We can't update sales order tables for that particular order.", you can update that order getting it from the observer Example:



                config.xml
                ...



                <events>
                <sales_order_invoice_save_after>
                <observers>
                <unique_identifier>
                <type>singleton</type>
                <class>Module_SalesOrder_Model_Observer</class>
                <method>updateDeliveryDate</method>
                </unique_identifier>
                </observers>
                </sales_order_invoice_save_after>
                </events>


                ...



                Observer



                class Module_SalesOrder_Model_Observer

                public function updateDeliveryDate(Varien_Event_Observer $observer)
                $_event = $observer->getEvent();
                $_invoice = $_event->getInvoice();
                $_order = $_invoice->getOrder();

                $_order->setDeliveryAt('2018-03-26 00:00:00');
                $_order->save();







                share|improve this answer













                Having in mind that "While creating invoice to particular order, We can't update sales order tables for that particular order.", you can update that order getting it from the observer Example:



                config.xml
                ...



                <events>
                <sales_order_invoice_save_after>
                <observers>
                <unique_identifier>
                <type>singleton</type>
                <class>Module_SalesOrder_Model_Observer</class>
                <method>updateDeliveryDate</method>
                </unique_identifier>
                </observers>
                </sales_order_invoice_save_after>
                </events>


                ...



                Observer



                class Module_SalesOrder_Model_Observer

                public function updateDeliveryDate(Varien_Event_Observer $observer)
                $_event = $observer->getEvent();
                $_invoice = $_event->getInvoice();
                $_order = $_invoice->getOrder();

                $_order->setDeliveryAt('2018-03-26 00:00:00');
                $_order->save();








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 '18 at 22:45









                ChristianDChristianD

                1033 bronze badges




                1033 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%2f213499%2fmagento-1-9-sales-flat-order-and-sales-flat-order-grid-tables-are-not-updating%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