Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 1.7 按钮重定向到网格页面_Magento 1.7_Magento - Fatal编程技术网

Magento 1.7 按钮重定向到网格页面

Magento 1.7 按钮重定向到网格页面,magento-1.7,magento,Magento 1.7,Magento,我有一个自定义模块“横幅”,我在其中的第二个选项卡中添加了一个按钮(模块只有两个选项卡)。当点击该按钮时,它会自动提交我的横幅,然后转到网格页面(即它只是另一个保存按钮)。但此按钮的功能是添加上载图像字段。即,每当单击此按钮时,它都应将图像表单字段添加到我的选项卡文件中。这是我的标签文件 <?php class Karaokeshop_Banner_Block_Adminhtml_Banner_Edit_Tab_Image extends Mage_Adminhtml_Block_Widg

我有一个自定义模块“横幅”,我在其中的第二个选项卡中添加了一个按钮(模块只有两个选项卡)。当点击该按钮时,它会自动提交我的横幅,然后转到网格页面(即它只是另一个保存按钮)。但此按钮的功能是添加上载图像字段。即,每当单击此按钮时,它都应将图像表单字段添加到我的选项卡文件中。这是我的标签文件

<?php
class Karaokeshop_Banner_Block_Adminhtml_Banner_Edit_Tab_Image extends Mage_Adminhtml_Block_Widget_Form
{

    protected function _prepareForm()
    {
        $form = new Varien_Data_Form();
        $this->setForm($form);
        $fieldset = $form->addFieldset('banner_image', array('legend'=>Mage::helper('banner')->__('Banner Image')));
        //declaring a new custom form field and adding
        $fieldset->addType('add_button', 'Karaokeshop_Banner_Block_Adminhtml_Banner_Edit_Tab_Field_Custom'); 
        $fieldset->addField('banner_img_add_button', 'add_button', array(
            'title' => Mage::helper('banner')->__('Add Banner Image'),
            'id' => 'add_banner_img_button',
            'class' => 'scalable save',
            'style' => '',
            'onclick' => 'banner.add(this)',
            'type' => 'button',                    
        ));

         return parent::_prepareForm();                                                    
    }  

} 

首先,您需要从块调用phtml,如下所示:

class My_Moudles_Block_Adminhtml_Image_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
   public function __construct()
  {

        parent::__construct();
        $this->setTemplate('modules/imageupload.phtml');
        $this->setFormAction(Mage::getUrl('*/*/imageupload'));


  }
<tbody id="email_chain_container">
            <?php  foreach($images as $row){ ?><tr>
   <td class="nobr">
                   your image code
                </td></tr>
然后在
adminhtml/default/default/template/yourmodule/imageupload.phtml
中创建文件,并将此代码放在那里

<div class="entry-edit">
    <div class="entry-edit-head">
    <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('General')?></h4>
    <div class="form-buttons"></div>
</div>
<form id="imageform" method="post" action="<? echo $this->getFormAction(); ?>">
    <div id="rules_form" class="fieldset ">
    <div class="hor-scroll">

                        <table cellspacing="0" class="form-list">
            <tbody>
          <tr>
    <td class="label"><?php echo $this->__('Add Image')?></td>
    <td class="grid tier" colspan="10">
    <table cellspacing="0" id="chain_tiers" class="chain border" style=" width:465px; ">
        <thead>
            <tr class="headings">

                <th><?php echo $this->__('Image')?></th>
                <th class="last"><?php echo $this->__('Action')?></th>
            </tr>
            <tr class="template no-display" id="email_chain_add_template">

                <td class="nobr">
                    <input type="file" id="chain_Image" value="0" name="imageg" class="requried-entry input-text">
                </td>

                <td class="last"><input type="hidden" value="" disabled="no-template" class="delete" name="email_chain[__index__][delete]"><button onclick="emailsControl.deleteItem(event);return false" class="scalable delete icon-btn delete-product-option" title="Delete Image"><span><?php echo $this->__('Delete')?></span></button></td>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <td></td>
                <td class="a-right" colspan="6">
                    <button style="" onclick="emailsControl.addItem()" class="scalable add" type="button" title="Add email" id="id"><span><span><span><?php echo $this->__('Add Image')?></span></span></span></button></td>
            </tr>
        </tfoot>
        <tbody id="email_chain_container">
                <tr>
                <td class="nobr">
                    <input type="file" id="chain_Image" value="" name="Image[]" class="input-text">
                </td>
                <td class="last"><input type="hidden" value="" class="delete" name="email_chain[delete][]"><button onclick="emailsControl.deleteItem(event);return false" class="scalable delete icon-btn delete-product-option" title="Delete Image"><span><?php echo $this->__('Delete')?></span></button></td>
            </tr>
              </tbody>
    </table>

<script type="text/javascript">
//&lt;![Cchain[

    var emailsControl = {
            itemsCount : 0,
            deleteButton : false,
            addItem : function () {
            var chain = {};
            chain.TEMPLATE_ID = 0;
            chain.index = this.itemsCount++;
            if (arguments.length == 1) {
            chain.TEMPLATE_ID = arguments[0];
            }
            var s = '<tr>' + $('email_chain_add_template').innerHTML.replace(/__index__/g, '#{index}').replace(/\sdisabled="?no-template"?/g, ' ').replace(/disabled/g, ' ').replace(/="'([^']*)'"/g, '="$1"') + '</tr>';
            var template = new Template(s); 

            Element.insert($('email_chain_container'), {'bottom': template.evaluate(chain)});
            $('chain_row_'+chain.index+'_TEMPLATE').value   = chain.TEMPLATE_ID;
            maxItemsCount++;

        },

        deleteItem : function(event) {
            var tr = Event.findElement(event, 'tr');
            if (tr) {
                jQuery(tr).remove();
            }
        }
    }
    var maxItemsCount = 2;
//]]&gt;
</script>
</td>
</tr>
            </tbody>
        </table>
            </div></form>
        </div>
</div>


使用phtml并设置自定义函数。这不是像您为按钮所做的那样编程的好方法。@MahmoodRehman感谢您的回复。在我的第二个选项卡中添加“添加”按钮的正确方法是什么?在第二个选项卡中,您想做什么?你在保存什么东西吗?你是说在我的选项卡文件中使用一个_construct()函数吗?请对你的选项卡代码也提出疑问。这不起作用。我已经在我的选项卡文件中添加了您的代码,还创建了phtml文件。但是现在我的图像选项卡(第二个选项卡)是空的。未显示任何字段因可能的错误而导致的Firebug。检查可能缺少一些html,这可能会导致清空,否则请删除缓存并再次检查。我已检查html代码。这是正确的,并且我已清除缓存并重试。但是仍然没有显示从phtml中删除所有代码,只显示“正在工作”并检查它是否工作?是的。现在它工作得很好。谢谢。你真聪明。现在需要根据以下内容更正saveaction()
<tbody id="email_chain_container">
            <?php  foreach($images as $row){ ?><tr>
   <td class="nobr">
                   your image code
                </td></tr>