0

i've been trying to include a block in the sales_order_shipment form.

I already got the block to appear at the bottom of the page, but everytime i press the ship button the information related to my block isn't sent (because it's not part of the original form).

This is what I've done so far:

In my module config.xml i added:

<global>
....
<blocks>
        <modulename>
            <class>Companyname_Modulename_Block</class>
        </modulename>
</blocks>
.....
</global>
<adminhtml>
    <layout>
        <updates>
            <Companyname_Modulename>
                <file>modulename.xml</file>
            </Companyname_Modulename>
        </updates>
    </layout>
</adminhtml>

Added modulename.xml to layout in (app/design/adminhtml/default/defaul/layout):

<layout>
<adminhtml_sales_order_shipment_new>
    <reference name="content">
            <block type="modulename/sales_order_shipment_create_atinfo" name="atinfo" template="modulename/sales/order/shipment/create/atinfo.phtml"></block>
    </reference>
</adminhtml_sales_order_shipment_new>

Added my template, named atinfo.phtml to (app/design/adminhtml/default/default/template/modulename/sales/order/shipment/create) with some simple html.

The problem seems to be that, by adding my block this way, it doesn't go into:

<form id="edit_form" method="post" action="<?php echo $this->getSaveUrl() ?>">

That is defined in form.phtml.

Is it possible, on my modulename.xml, to insert the block (name=atinfo) inside the block (name=form) that is defined on sales.xml (located at /app/design/adminhtml/default/default/layout)?

Right now, if we insert the block (name=form) inside modulename.xml, it gets duplicated on the order new shipment page.

Any help would be appreciated, as i said before, my block appears in the page, but when i press the Ship button, my block information isn't sent.

1

I recommend that you take the form.phtml, copy it, then customize it inside your module.

Put customForm.phtml in design/adminhtml/default/default/template/modulename/. Next, you will need to enter the new customForm.phtml into your xml layout file. Copy over the Mage/core/adminhtml/etc/config.xml entry for

<adminhtml_sales_order_shipment_new>  

Copy that whole node. You're going to need all the block entries to do a succesful override. Then, change the specific form call to your custom form. The ... in the code below denotes all the other xml you will have copied over.

<layout>
    <adminhtml_sales_order_shipment_new>
        ...
        <reference name="content">
            ...
            <block type="adminhtml/sales_order_shipment_create_form" template="modulename/customForm.phtml">    
            </block>
            ...
        </reference>
    </adminhtml_sales_order_shipment_new>
</layout>

This way, you can customize the form to your hearts content, and the post action will include your variables.

Notice that I did not change the type. You do not need to change this specific block to do what you're doing. If you look at Mage_Adminhtml_Sales_Order_Shipment_Create_Form, you'll see all it does is execute layout calls, assign urls, child html, etc. You can probably leave it alone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.