Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7786047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:21:14+00:00 2026-06-01T20:21:14+00:00

hi Guys I have a problem with form action of a form generated by

  • 0

hi
Guys I have a problem with form action of a form generated by admin panel of magento for a custom module.

This is the structure of my files under app/code/local/Namespace/Zipcodes/Block

Block
|
|____Adminhtml
    |
    |____ Importblock
        |
        |__Edit
        |   |__Form.php
        |   |__Tabs.php
        |   |
        |   |__Tab
        |       |___Form.php
        |
        |__Edit.php
        |
        |
        Zipcodes
        |
        |__Edit
        |   |__Form.php   // << this file is getting called in importblock form
        |   |__Tabs.php
        |   |
        |   |__Tab
        |       |___Form.php
        |
        |__Edit.php

This is my action method of ZipcodesController.php

public function importAction()
{

    if ($data = $this->getRequest()->getPost() && isset($_FILES['csv_file']['name']) )
    {
        echo '<br> hi ! we  uploaded the file';
    }
    $this->_initAction();

    $this->_addContent($this->getLayout()->createBlock('zipcodes/adminhtml_importblock_edit'))
          ->_addLeft($this->getLayout()->createBlock('zipcodes/adminhtml_importblock_edit_tabs'));

    $this->renderLayout();
}

This is my Block/Adminhtml/Importblock/Edit.php

<?php 
  class Namespace_Zipcodes_Block_Adminhtml_Importblock_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
    public function __construct()
   {
    parent::__construct();
    $this->_objectId = 'id';
    $this->_blockGroup = 'zipcodes';
    $this->_controller = 'adminhtml_zipcodes';
    $this->_updateButton('save', 'label', Mage::helper('zipcodes')->__('Upload file'));

}

public function getHeaderText()
{   
    return Mage::helper('zipcodes')->__('Import Zipcode data');

}

}

This is my Block/Adminhtml/Importblock/Edit/Tab/Form.php

class Namespace_Zipcodes_Block_Adminhtml_Importblock_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
      {

    $form = new Varien_Data_Form(array(
            'id' => 'edit_form',
            'action' => $this->getUrl('*/*/import'),
            'method' => 'post',
            'enctype' => 'multipart/form-data'
        )
    );
    $this->setForm($form);
    //echo '<br>form.php bahar<pre>';print_r(get_class_methods(get_class($form))); echo '</pre>';
    $fieldset = $form->addFieldset('zipcodes_form', array('legend'
                    => Mage::helper('zipcodes')->__('Provide data file')));

    $fieldset->addField('csv_file', 'file', array(
                    'label' => Mage::helper('zipcodes')->__('CSV File'),
                    'class' => 'required-entry',
                    'required' => true,
                    'name' => 'csv_file',
            ));

    return parent::_prepareForm();
}
 }

this is my Block/Adminhtml/Importblock/Edit/Tabs.php

class Namespace_Zipcodes_Block_Adminhtml_Importblock_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{
public function __construct()
{
    parent::__construct();
    $this->setId('zipcode_import_tabs');
    $this->setDestElementId('edit_form');
    $this->setTitle(Mage::helper('zipcodes')->__('Import Zipcodes'));
}

protected function _beforeToHtml()
{
    $this->addTab('form_section', array(
            'label' => Mage::helper('zipcodes')->__('Zipcode Info'),
            'title' => Mage::helper('zipcodes')->__('Zipcode Info'),
            'content' => $this->getLayout()
                ->createBlock('zipcodes/adminhtml_importblock_edit_tab_form')->toHtml(),
            'active'    => true
        ));

    return parent::_beforeToHtml();
}
}

& last this is my Block_Adminhtml_Importblock_Edit_Form.php

class Namespace_Zipcodes_Block_Adminhtml_Importblock_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $form = new Varien_Data_Form(array(
                'id' => 'edit_form',
                'action' => $this->getUrl('*/*/import'),
                'method' => 'post',
            )
        );

        $form->setUseContainer(true);
        $this->setForm($form);
        return parent::_prepareForm();
    }
}

when I run the code The last file doesn’t gets called. as I am using $this->_addContent($this->getLayout()->createBlock('zipcodes/adminhtml_importblock_edit')) in code due to this when form gets rendered I see the form action action as /save instead of /import

So I changed the Block_Adminhtml_Importblock_Edit_Tab_Form & wrote

$form = new Varien_Data_Form(array(
            'id' => 'edit_form',
            'action' => $this->getUrl('*/*/import'),
            'method' => 'post',
            'enctype' => 'multipart/form-data'
        )
    );

But still its showing form action as /save not /import. Can anybody help me with this


Guys I have found one more clue

the file under Adminhtml/Zipcodes/Edit/Form.php is getting called in importblock’s form
thats why the action is not getting set at runtime.
Now can anyone help me how to remove this error & make the correct reference to Adminhtml/Importblock/Edit/Form.php

Thanks Please its so close help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:21:14+00:00Added an answer on June 1, 2026 at 8:21 pm

    This comes a bit late but might be helpful for others that get this issue.

    In your Namespace_Zipcodes_Block_Adminhtml_Importblock_Edit class you have:

    $this->_objectId = 'id';
    $this->_blockGroup = 'zipcodes';
    $this->_controller = 'adminhtml_zipcodes';
    

    but there is a property missing: $this->_mode

    Setting $this->_mode to 'import' will help you get the right action.

    $this->_objectId = 'id';
    $this->_blockGroup = 'zipcodes';
    $this->_controller = 'adminhtml_zipcodes';
    $this->_mode       = 'import'
    

    After changing this you will get the right action for your form.

    The default mode is edit:

    class Mage_Adminhtml_Block_Widget_Form_Container extends     Mage_Adminhtml_Block_Widget_Container
    {
    protected $_objectId = 'id';
    protected $_formScripts = array();
    protected $_formInitScripts = array();
    protected $_mode = 'edit';
    protected $_blockGroup = 'adminhtml';
    

    the the function for _prepareLayout():

    protected function _prepareLayout()
    {
        if ($this->_blockGroup && $this->_controller && $this->_mode) {
            $this->setChild('form', $this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'));
        }
        return parent::_prepareLayout();
    }
    

    As you can see instead of your block, default you get the edit_form block.

    Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok guys, I have a serious problem with this. I have a static class
I hope some of you guys can help me with this problem.... I have
Guys i have a little problem when i submit my form the page gets
Guys, I have a windows form with a panel control and inside the panel
please help me out with this problem.I have a contact form like this: <div
Hi guys I have a problem with cookies on firefox I'm submitting a form
Hi guys i have a problem i my code i set a datepicker with
Hey guys, I have a weird problem. I have an update system that refreshes
Thus far you guys have been wildly helpful with me getting this little ditty
guys i have arrays in which i have to match this kind of text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.