2

magento\app\etc\modules\Svi_Form.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Svi_Form>
            <active>true</active>
            <codePool>local</codePool>
        </Svi_Form>
    </modules>
</config>

app\code\local\Svi\Form\controllers\IndexController.php

<?php
Class Svi_Form_IndexController extends Mage_Core_Controller_Front_Action{
    public function indexAction(){
        $layout =$this->loadLayout();
        $this->renderLayout();
    }

    public function postAction(){
        $post = $this->getRequest()->getPost();
        print_r($post);exit;
    }

}
?>

app\code\local\Svi\Form\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Svi_Form>
            <version>0.1.0</version>
        </Svi_Form>
    </modules>

    <frontend>
        <routers>
            <form>
                <use>standard</use>
                <args>
                    <module>Svi_Form</module>
                    <frontName>form</frontName>
                </args>
            </form>
        </routers>
        <layout>
            <updates>
                <form>
                    <file>form.xml</file>
                </form>
            </updates>
        </layout>
    </frontend>
    <global>
        <models>
            <form>
                <class>Svi_Form_Model</class>
                <resourceModel>form_mysql4</resourceModel>
            </form>
            <form_mysql4>
                <class>Svi_Form_Model_Mysql4</class>
                <entities>
                    <form>
                        <table>svi_form</table>
                    </form>
                </entities>
            </form_mysql4>
        </models>
        <resources>
            <form_setup>
                <setup>
                    <module>Svi_Form</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </form_setup>
            <form_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </form_write>
            <form_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </form_read>
        </resources>
        <blocks>
            <form>
                <class>Svi_Form_Block</class>
            </form>
        </blocks>
        <helpers>
            <form>
                <class>Svi_Form_Helper</class>
            </form>
        </helpers>
    </global>
</config>

app\code\local\Svi\Form\Block\Form.php

<?php
class Svi_Form_Block_Form extends Mage_Core_Block_Template 
{   

}

app\code\local\Svi\Form\Helper\Data.php

<?php
class Svi_Form_Helper_Data extends Mage_Core_Helper_Abstract
{

}

app\code\local\Svi\Form\Model\Form.php

<?php
class Svi_Form_Model_Form extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('form/form');
    }
}

app\code\local\Svi\Form\Model\Mysql4\Form.php

<?php
class Svi_Form_Model_Mysql4_Form extends Mage_Core_Model_Mysql4_Abstract
{
    public function _construct()
    {   
        $this->_init('form/form', 'prical_id');
    }
}

app\code\local\Svi\Form\Model\Mysql4\Form\Collection.php

<?php
class Svi_Form_Model_Mysql4_Form_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
    public function _construct()
    {
        //parent::__construct();
        $this->_init('form/form');
    }
}

app\code\local\Svi\Form\sql\form_setup\mysql4-install-0.1.0.php

<?php
$installer = $this;

$installer->startSetup();

$installer->run("

-- DROP TABLE IF EXISTS {$this->getTable('svi_form')};
CREATE TABLE {$this->getTable('svi_form')} (
  `prical_id` int(11) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `content` text NOT NULL default '',
  `status` smallint(6) NOT NULL default '0',
  `created_time` datetime NULL,
  `update_time` datetime NULL,
  PRIMARY KEY (`prical_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    ");

$installer->endSetup();

Please tell me what is my mistake here. It is not createing table. I am new on Magento that's why I asked this question. Thanks.............

6
  • clear your cache and check it works Aug 3, 2015 at 8:43
  • could you share your module via .git?
    – zhartaunik
    Aug 3, 2015 at 8:51
  • Hi @saravanavelu I cleared my cache many times but it did not work. Aug 3, 2015 at 10:19
  • check your form_setup is exists in core_resource table. If exists, remove that record. then clear cache and then check ur table created and reocrd in core resource table Aug 3, 2015 at 10:22
  • @ saravanavelu form_setup is not exist in core_resource table. what to do? Aug 3, 2015 at 10:56

1 Answer 1

3

Delete the setup entry (for this module) in core_resource table

Disable the cache.

Refresh any page

Check the database

I have checked your code it working fine. Just disable cached or flush the cached

7
  • I tried again as you told but it does not work.... Aug 3, 2015 at 11:58
  • try to put the die in your sql file. Is your module is coming under system->advance module list? Aug 3, 2015 at 12:08
  • Yes my module is coming under system->configuration->advanced and It is enabled. Aug 3, 2015 at 12:14
  • Can you tell me what the mean of ("try to put the die in your sql file")? Aug 3, 2015 at 12:34
  • 1
    I think it was the problem of the cache as it was working in my magento with very first installation of module Aug 5, 2015 at 7:00

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.