0

I have been tasked with creating some custom html ( a drop down with button ) in the adminhtml - grid.php. On button click (or update) an ajax call will then update the record in the database. I have a file called warrantyClaim.phtml that I have placed in the \app\design\adminhtml\default\default\template\myapp\warrantyclaim folder

here is what the html looks like in the grid:

<select name="warrantyStatus" id="warrantyStatus" claim="33329">
<option value="0">Not Submitted</option>
<option value="1">Submitted</option>
<option value="2">Pending Approval</option>
<option value="3">Approved</option>
<option value="4" selected="">Partially Approved</option>
<option value="5">Declined</option>
</select>

<button style="display: inline-block;" onclick="updateTitle(this, 33329); return false">Update</button>

Here is the code for my warrantyClaim.phtm file:

<script type="text/javascript">
function updateTitle(button, fieldId)
{
new Ajax.Request('<?php echo Mage::helper('adminhtml')->getUrl('*/*/updateTitle') ?>', {
    method: 'post',
    parameters: { id: fieldId, title: $(button).previous('warrantyStatus').getValue() }
});
}

On button click, I get a javascript error, stating the function updateTitle is not defined, which tells me that my warrantyClaim.phtml is missing. Did I miss another step? I just placed the warrantyClaim.phtml file into the folder.

  • phtml files only get called as a template for blocks. Unless you define so in the layout.xml or call in the php class of the block, it won't be loaded. Since it is all javascript, though, I would make it a .js file and add it with the local.xml into the head of the page. – user3154108 Sep 19 '14 at 12:46
  • can you make that the answer? if so i will accept it as the answer and thanks! – Matthew Colley Sep 19 '14 at 12:53
2

phtml files only get called as a template for blocks. Unless you define so in the layout.xml or call it in the php class of the block, it won't be loaded. Since it is all javascript, though, I would make it a .js file and add it with the local.xml into the head of the page with the addJs method.

1

You will need to call that template in the layout XML. in myapp/warrantyclaim/etc/config.xml add

<layout>
    <myapp_warrantyclaim>
        <reference name="head">
            <block type="myapp/warrantyclaim" name="warrantyclaim" template="warrantyclaim/warrantyClaim.phtml"/>
        </reference>
    </myapp_warrantyclaim>
</layout>

You may need to modify to fit your exact paths but hopefully this helps.

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.