0

here is all my file

app\code\local\Sample\Bigcom\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Sample_Bigcom>
            <version>1.0.0</version>
        </Sample_Bigcom>
    </modules>
    <global>
    <blocks>
            <sample_bigcom>
                <class>Sample_Bigcom_Block</class>
            </sample_bigcom>
        </blocks>
        <helpers>
    <sample_bigcom>
      <class>Sample_Bigcom_Helper</class>
    </sample_bigcom>
  </helpers>
        <helpers>
            <sample_bigcom>
                <!-- Helper definition needed by Magento -->
                <class>Mage_Core_Helper</class>
            </sample_bigcom>
        </helpers>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Sample_Bigcom before="Mage_Adminhtml">Sample_Bigcom_Adminhtml</Sample_Bigcom>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <layout>
    <updates>
        <sample_bigcom>
            <file>sample_bigcom.xml</file>
        </sample_bigcom>
    </updates>
</layout>
</config>

app\code\local\Sample\Bigcom\etc\adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <menu>
        <mycustomtab module="sample_bigcom" translate="title">
            <title>My Custom Tab</title>
            <sort_order>100</sort_order>
            <children>
                <index module="sample_bigcom" translate="title">
                    <title>Index Action</title>
                    <sort_order>10</sort_order>
                    <action>adminhtml/bigcom</action>
                </index>
            </children>
        </mycustomtab>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <sample>
                        <title>My Custom Tab</title>
                        <sort_order>100</sort_order>
                        <children>
                            <index>
                                <title>Index Action</title>
                                <sort_order>10</sort_order>
                            </index>
                        </children>
                    </sample>
                </children>
            </admin>
        </resources>
    </acl>
</config>

app\code\local\Sample\Bigcom\Helper\Data.php

<?php
/**
 * Adminhtml base helper
 *
 * @category   Mageworks
 * @package    Mageworks_Import
 * @author     mageworks kumar <[email protected]>
 */
class Sample_Bigcom_Helper_Data extends Mage_Core_Helper_Abstract
{
}

app\code\local\Sample\Bigcom\Block\Adminhtml\Form\Edit.php

<?php

class Sample_Bigcom_Block_Adminhtml_Form_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{

    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();

        $this->_objectId = 'edit_form';
        $this->_blockGroup = 'sample_bigcom';
        $this->_controller = 'adminhtml_form';

        $this->_updateButton('save', 'label', Mage::helper('sample_bigcom')->__('Save'));
        $this->_updateButton('delete', 'label', Mage::helper('sample_bigcom')->__('Delete'));

    }

    public function getHeaderText()
    {
        return Mage::helper('sample_bigcom')->__('My Form Container');
    }

}

app\code\local\Sample\Bigcom\Block\Adminhtml\Form\Edit\Form.php

<?php

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

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

app\code\local\Sample\Bigcom\Block\Adminhtml\Form\Edit\Tabs.php

<?php
class Sample_Bigcom_Block_Adminhtml_Form_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{

  public function __construct()
  {
      parent::__construct();
      $this->setId('form_tabs');
      $this->setDestElementId('edit_form'); // this should be same as the form id define above
      $this->setTitle(Mage::helper('sample_bigcom')->__('Product Information'));
  }

  protected function _beforeToHtml()
  {
      $this->addTab('form_section', array(
          'label'     => Mage::helper('sample_bigcom')->__('Item Information'),
          'title'     => Mage::helper('sample_bigcom')->__('Item Information'),
          'content'   => $this->getLayout()->createBlock('sample_bigcom/adminhtml_form_edit_tab_form')->toHtml(),
      ));

      return parent::_beforeToHtml();
  }
}

this is controller file app\code\local\Sample\Bigcom\controllers\Adminhtml\BigcomController.php

  <?php

class Sample_Bigcom_Adminhtml_BigcomController extends Mage_Adminhtml_Controller_Action
{


    /**
     * View form action
     */
   public function indexAction()
    {
        $this->loadLayout()
            ->_setActiveMenu('mycustomtab')
            ->_title($this->__('Index Action'));
$block11=$this->getLayout()->createBlock('sample_bigcom/adminhtml_form_edit_form');
$this->getResponse()->setBody($block11->toHtml());
$block=$this->getLayout()->createBlock('sample_bigcom/adminhtml_form_edit');
$this->getResponse()->setBody($block->toHtml());
        // my stuff

        $this->renderLayout();
    }
    public function saveAction()
    {
        echo "hiii";
    }


}
app\etc\Sample_Bigcom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <modules>
            <Sample_Bigcom>
                <active>true</active>
                <codePool>local</codePool>
            </Sample_Bigcom>
        </modules>
    </config>

this is layout file

app\design\adminhtml\default\default\layout\sample_bigcom.xml

<?xml version="1.0"?>
<layout version="1.0.0">

    <adminhtml_bigcom_index>
        <update handle="editor"/>
        <reference name="content">
            <block type="sample_bigcom/adminhtml_form_edit" name="bigcom"/>
        </reference>
        <reference name="left">
            <block type="sample_bigcom/adminhtml_form_edit_tabs" name="bigcom_tabs"/>
        </reference>
    </adminhtml_bigcom_index>

</layout>

every time when i click Index Action tab i got only Edit.php file output and give error like varienForm is not defined

2
  • can you edit your question and include path to the files? Commented Aug 8, 2015 at 6:14
  • i updated my question...and i also edit BigcomController file now it give only Edit.php file layout and give one error like varienForm is not defined
    – mit patel
    Commented Aug 8, 2015 at 6:23

3 Answers 3

0

You're calling

$this->getLayout()->createBlock('sample_bigcom/adminhtml_form_edit_tab_form')->toHtml()

But your block class is

Sample_Bigcom_Block_Adminhtml_Form_Edit_Form

You're missing the tab in your class and make sure that's where the file lives as well so Sample/Bigcom/Block/Adminhtml/Form/Edit/Tab/Form.php.

2
  • i already try this but didn't work
    – mit patel
    Commented Aug 8, 2015 at 6:31
  • Is the file located at Sample/Bigcom/Block/Adminhtml/Form/Edit/Tab/Form.php? Is there anything in the exception.log
    – rob3000
    Commented Aug 8, 2015 at 6:35
0

in your config file, instead of <sample_bigcom> use <Sample_Bigcom>. It is case sensitive.

UPDATE

$this->getLayout()->createBlock('sample_bigcom/adminhtml_form_edit_form')->toHtml()

instead of

$this->getLayout()->createBlock('sample_bigcom/adminhtml_form_edit_tab_form')->toHtml()

in app\code\local\Sample\Bigcom\Block\Adminhtml\Form\Edit\Tabs.php

2
0

i just got my solution i make update in my layout file added this two line

<reference name="content11">
            <block type="sample_bigcom/adminhtml_form_edit_form" name="bigcom_form"/>
        </reference>

and also change Form.php file

<?php

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

        $form->setUseContainer(true);
        $this->setForm($form);
        $fieldset = $form->addFieldset('bigcom_form', array('legend'=>Mage::helper('sample_bigcom')->__('Project information')));
 $fieldset->addField('file', 'file', array(
          'label'     => Mage::helper('sample_bigcom')->__('Upload'),
          'name'  => 'csvupload',
          'value'  => 'Uplaod',
        //  'after_element_html' => '<small>Comments</small>',
          'tabindex' => 1
        ));

        $fieldset->addField('submit', 'submit', array(
          'label'     => Mage::helper('sample_bigcom')->__('Submit'),
          //'required'  => true,
          'value'  => 'Submit',
          //'after_element_html' => '<small>Comments</small>',
          'tabindex' => 2
        ));
       return parent::_prepareForm();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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