title: Fatal error: Call to a member function getIdFieldName() on a non-object in Magento
body: <p>I have created a custom module in both frontend and backend called vendor complaints, I am getting the form, but when i fill the details and click on save I am getting the fatal error.</p>
  
  <p>My Config.xml file:</p>
  
  <pre><code>     &lt;?xml version="1.0"?&gt;
          &lt;config&gt;
            &lt;modules&gt;
              &lt;Blazedream_VendorComplaints&gt;
                &lt;version&gt;0.1.0&lt;/version&gt;
              &lt;/Blazedream_VendorComplaints&gt;
            &lt;/modules&gt;
            &lt;frontend&gt;
              &lt;routers&gt;
                &lt;vendorcomplaints&gt;
                  &lt;use&gt;standard&lt;/use&gt;
                    &lt;args&gt;
                      &lt;module&gt;Blazedream_VendorComplaints&lt;/module&gt;
                      &lt;frontName&gt;vendorcomplaints&lt;/frontName&gt;
                    &lt;/args&gt;
                &lt;/vendorcomplaints&gt;
              &lt;/routers&gt;
              &lt;layout&gt;
                    &lt;updates&gt;
                      &lt;vendorcomplaints&gt;
                        &lt;file&gt;vendorcomplaints.xml&lt;/file&gt;
                      &lt;/vendorcomplaints&gt;
                    &lt;/updates&gt;
              &lt;/layout&gt;
            &lt;/frontend&gt;
            &lt;global&gt;
              &lt;helpers&gt;
                &lt;vendorcomplaints&gt;
                  &lt;class&gt;Blazedream_VendorComplaints_Helper&lt;/class&gt;
                &lt;/vendorcomplaints&gt;
              &lt;/helpers&gt;
              &lt;blocks&gt;
                &lt;vendorcomplaints&gt;
                  &lt;class&gt;Blazedream_VendorComplaints_Block&lt;/class&gt;
                &lt;/vendorcomplaints&gt;
              &lt;/blocks&gt;
              &lt;models&gt;
                &lt;vendorcomplaints&gt;
                  &lt;class&gt;Blazedream_VendorComplaints_Model&lt;/class&gt;
                  &lt;resourceModel&gt;VendorComplaints_mysql4&lt;/resourceModel&gt;
                &lt;/vendorcomplaints&gt;
                &lt;vendorcomplaints_mysql4&gt;
                  &lt;class&gt;Blazedream_VendorComplaints_Model_Mysql4&lt;/class&gt;
                  &lt;entities&gt;        
                        &lt;complaints&gt;
                          &lt;table&gt;vendor_complaints&lt;/table&gt;
                        &lt;/complaints&gt;
                  &lt;/entities&gt;
                &lt;/vendorcomplaints_mysql4&gt;
              &lt;/models&gt;
              &lt;resources&gt;
                &lt;vendorcomplaints_setup&gt;
                  &lt;setup&gt;
                    &lt;module&gt;Blazedream_VendorComplaints&lt;/module&gt;
                  &lt;/setup&gt;
                  &lt;connection&gt;
                    &lt;use&gt;core_setup&lt;/use&gt;
                  &lt;/connection&gt;
                &lt;/vendorcomplaints_setup&gt;
                &lt;vendorcomplaints_write&gt;
                  &lt;connection&gt;
                    &lt;use&gt;core_write&lt;/use&gt;
                  &lt;/connection&gt;
                &lt;/vendorcomplaints_write&gt;
                &lt;vendorcomplaints_read&gt;
                  &lt;connection&gt;
                    &lt;use&gt;core_read&lt;/use&gt;
                  &lt;/connection&gt;
                &lt;/vendorcomplaints_read&gt;
              &lt;/resources&gt;
            &lt;/global&gt;
             &lt;admin&gt;
              &lt;routers&gt;
                &lt;vendorcomplaints&gt;
                  &lt;use&gt;admin&lt;/use&gt;
                  &lt;args&gt;
                    &lt;module&gt;Blazedream_VendorComplaints&lt;/module&gt;
                    &lt;frontName&gt;vendorcomplaints&lt;/frontName&gt;
                  &lt;/args&gt;
                &lt;/vendorcomplaints&gt;
              &lt;/routers&gt;
            &lt;/admin&gt;
             &lt;adminhtml&gt;
              &lt;menu&gt;
              &lt;marketplace&gt;
                  &lt;children&gt;
                      &lt;complaints module="vendorcomplaints"&gt;
                      &lt;title&gt;Manage Complaints&lt;/title&gt;
                      &lt;sort_order&gt;0&lt;/sort_order&gt;
                      &lt;action&gt;admin_vendorcomplaints/adminhtml_complaints&lt;/action&gt;
                    &lt;/complaints&gt;
                  &lt;/children&gt;
              &lt;/marketplace&gt;
              &lt;/menu&gt;
              &lt;acl&gt;
                  &lt;resources&gt;
                      &lt;all&gt;
                      &lt;title&gt;Allow Everything&lt;/title&gt;
                      &lt;/all&gt;
                      &lt;admin&gt;
                          &lt;children&gt;
                              &lt;vendorcomplaints&gt;
                                  &lt;title&gt;Complaints Module&lt;/title&gt;
                                  &lt;sort_order&gt;200&lt;/sort_order&gt;
                              &lt;/vendorcomplaints&gt;
                          &lt;/children&gt;
                      &lt;/admin&gt;
                  &lt;/resources&gt;
              &lt;/acl&gt;
              &lt;layout&gt;
                &lt;updates&gt;
                  &lt;vendorcomplaints&gt;
                    &lt;file&gt;vendorcomplaints.xml&lt;/file&gt;
                  &lt;/vendorcomplaints&gt;
                &lt;/updates&gt;
              &lt;/layout&gt;
            &lt;/adminhtml&gt;
          &lt;/config&gt; 
  </code></pre>
  
  <p>My Controller file:
  local/Blazedream/VendorComplaints/controllers/indexcontroller.php</p>
  
  <pre><code>        &lt;?php
      class Blazedream_VendorComplaints_IndexController extends Mage_Core_Controller_Front_Action{
  
          public function IndexAction() {
            $this-&gt;checkurlForVendor();
            $this-&gt;loadLayout();   
            $this-&gt;getLayout()-&gt;getBlock("head")-&gt;setTitle($this-&gt;__("Seller Complaints"));
                  $breadcrumbs = $this-&gt;getLayout()-&gt;getBlock("breadcrumbs");
            $breadcrumbs-&gt;addCrumb("home", array(
                      "label" =&gt; $this-&gt;__("Home Page"),
                      "title" =&gt; $this-&gt;__("Home Page"),
                      "link"  =&gt; Mage::getBaseUrl()
                 ));
  
            $breadcrumbs-&gt;addCrumb("Seller Complaints", array(
                      "label" =&gt; $this-&gt;__("Seller Complaints"),
                      "title" =&gt; $this-&gt;__("Seller Complaints")
                 ));
  
            $this-&gt;renderLayout(); 
  
          }
          public function saveAction()
          {
              $post_data=$this-&gt;getRequest()-&gt;getPost();
              $roleId = Mage::getSingleton('customer/session')-&gt;getCustomerGroupId();
              $role = Mage::getSingleton('customer/group')-&gt;load($roleId)-&gt;getData('customer_group_code');
              $role = strtolower($role);
              $post_data['customer_group']=$role;
              $customerName=$post_data['name'];
              $customerEmail=$post_data['email_id'];
              if ($post_data) {
                  try {
                      $model = Mage::getModel("vendorcomplaints/complaints")
                          -&gt;addData($post_data)
                          -&gt;setId($this-&gt;getRequest()-&gt;getParam("id"))
                          -&gt;save();
                      Mage::getSingleton('core/session')-&gt;addSuccess('Vendor Complaints was successfully saved');
                      $this-&gt;_redirect("*/*/");
                      return;
                  } 
                  catch (Exception $e) {
                      Mage::getSingleton("adminhtml/session")-&gt;addError($e-&gt;getMessage());
                      Mage::getSingleton("adminhtml/session")-&gt;setComplaintsData($this-&gt;getRequest()-&gt;getPost());
                      $this-&gt;_redirect("*/*/edit", array("id" =&gt; $this-&gt;getRequest()-&gt;getParam("id")));
                      return;
                  }
              }
              $this-&gt;_redirect("*/*/");
          }
          protected function _getSession()
              {
                  return Mage::getSingleton('customer/session');
              }
              protected function checkVendorIsActive()
          {
              return Mage::helper('marketplace')-&gt;getVendorStatus();
          }
  
          function checkvendorisLogged(){
               $session = $this-&gt;_getSession();
               if (!$session-&gt;isLoggedIn()) {
                  Mage::getSingleton('customer/session')-&gt;addError(Mage::helper('marketplace')-&gt;__("Please Login to your account"));
                  $this-&gt;_redirect('sellerlogin');
               }
          }
              public function checkurlForVendor()
              {
              $session = $this-&gt;_getSession();
  
              if (!$session-&gt;isLoggedIn()) {
                  Mage::getSingleton('customer/session')-&gt;addError(Mage::helper('marketplace')-&gt;__("Please login as seller"));
                  $this-&gt;_redirect('sellerlogin');
              } else {
                  $isEnable        = Mage::getStoreConfig('marketplace/general/enable');
                  $isModuleEnabled = Mage::helper('core')-&gt;isModuleOutputEnabled('NextBits_Marketplace');
                  $isActive        = $this-&gt;checkVendorIsActive();
                  $action_name = trim($this-&gt;getRequest()-&gt;getActionName());
  
                  if ($isModuleEnabled &amp;&amp; $isEnable){
  
  
                      if ($isActive == 0 || $isActive == "") {
                          Mage::getSingleton('customer/session')-&gt;addError(Mage::helper('marketplace')-&gt;__("Seller not activated yet, or you are not a seller."));
                          $this-&gt;_redirect('marketplace/vendor/dashboard/');
                      }
  
                  } else {
  
                      Mage::getSingleton('customer/session')-&gt;addError(Mage::helper('marketplace')-&gt;__("Marketplace Module is disable."));
                      $this-&gt;_redirect('marketplace/vendor/dashboard/');
                  }
              }
          }
      }
  </code></pre>
  
  <p>My Block File:
          local/Blazedream/VendorComplaints/Block/index.php</p>
  
  <pre><code>    &lt;?php   
          class Blazedream_VendorComplaints_Block_Index extends Mage_Core_Block_Template{   
  
              public function __construct(){
  
                      parent::__construct();
                      $this-&gt;setTemplate('vendorcomplaints/index.phtml');
              }
              protected function _prepareLayout()
              {
                  $this-&gt;setChild('save_button',
                          $this-&gt;getLayout()-&gt;createBlock('adminhtml/widget_button')
                              -&gt;setData(array(
                                  'label'     =&gt; Mage::helper('vendorcomplaints')-&gt;__('Submit'),
                                  'onclick'   =&gt; 'vendorComplaints.submit()',
                                  'class' =&gt; 'save'
                              ))
                      );
                  parent::_prepareLayout();
              }
              public function getBackButtonHtml()
              {
                  return $this-&gt;getChildHtml('back_button');
              }
  
              public function getCancelButtonHtml()
              {
                  return $this-&gt;getChildHtml('reset_button');
              }
  
              public function getSaveButtonHtml()
              {
                  return $this-&gt;getChildHtml('save_button');
              }
  
              public function getSaveAndEditButtonHtml()
              {
                  return $this-&gt;getChildHtml('save_and_edit_button');
              }
  
              public function getDeleteButtonHtml()
              {
                  return $this-&gt;getChildHtml('delete_button');
              }
  
              public function getDuplicateButtonHtml()
              {
                  return $this-&gt;getChildHtml('duplicate_button');
              }
               public function getValidationUrl()
              {
                  return $this-&gt;getUrl('*/*/validate', array('_current'=&gt;true));
              }
  
              public function getSaveUrl()
              {
                  return $this-&gt;getUrl('*/*/save', array('_current'=&gt;true, 'back'=&gt;null));
              }
          }
  </code></pre>
  
  <p>My form block file for creating the form:
  ocal/Blazedream/VendorComplaints/Block/Complaints/Edit/Form.php</p>
  
  <pre><code>       &lt;?php
       class Blazedream_VendorComplaints_Block_Complaints_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
      {
      protected function _prepareForm()
      {
              $customer = Mage::getSingleton('customer/session')-&gt;getCustomer();
              $customerId=$customer-&gt;getId();
              $data = Mage::getModel('marketplace/vendor')
                  -&gt;getCollection()
                  -&gt;addFieldToFilter('customer_id',$customerId)
                  -&gt;getData();
  
              $cus_name=$customer-&gt;getName();
              $emailId=$customer-&gt;getEmail();
              $form = new Varien_Data_Form();
              $this-&gt;setForm($form);
              $fieldset = $form-&gt;addFieldset("vendorcomplaints_form", array("legend"=&gt;Mage::helper("vendorcomplaints")-&gt;__("Item information")));
  
              $three_columns = "col-xs-12 col-sm-4 col-md-4 col-lg-4";
              $one_column = "col-xs-12 col-sm-12 col-md-12 col-lg-12";
  
                      $fieldset-&gt;addField("vendor_complaints_id", "hidden", array(
                      "label" =&gt; Mage::helper("vendorcomplaints")-&gt;__("Id"),
                      "name" =&gt; "vendor_complaints_id",
                      ));
  
                      $fieldset-&gt;addField("name", "text", array(
                      "label" =&gt; Mage::helper("vendorcomplaints")-&gt;__("First Name"),
                      "name" =&gt; "name",
                      "class"=&gt; "required-entry",
                      'readonly'=&gt;true,
                      'required' =&gt; true,
                      'value' =&gt;$cus_name,
                      'container_class' =&gt; $three_columns
                      ));
  
                      $fieldset-&gt;addField("order_id", "text", array(
                      "label" =&gt; Mage::helper("vendorcomplaints")-&gt;__("Order Id"),
                      "name" =&gt; "order_id",
                      'required' =&gt; true,
                      "class"=&gt; "required-entry",
                      'container_class' =&gt; $three_columns
                      ));
  
                      $fieldset-&gt;addField("email_id", "text", array(
                      "label" =&gt; Mage::helper("vendorcomplaints")-&gt;__("Email Id"),
                      "name" =&gt; "email_id",
                      'value'=&gt;$emailId,
                      'required' =&gt; true,
                      'readonly'=&gt;true,
                      "class"=&gt; "required-entry validate-email",
                      'container_class' =&gt; $three_columns
                      ));
  
                      $fieldset-&gt;addField("reason", "textarea", array(
                      "label" =&gt; Mage::helper("vendorcomplaints")-&gt;__("Reason"),
                      "name" =&gt; "reason",
                      'required' =&gt; true,
                      "class"=&gt; "required-entry",
                      'container_class' =&gt; $one_column
                      ));             
  
              if (Mage::getSingleton("adminhtml/session")-&gt;getComplaintsData())
              {
                  $form-&gt;setValues(Mage::getSingleton("adminhtml/session")-&gt;getComplaintsData());
                  Mage::getSingleton("adminhtml/session")-&gt;setComplaintsData(null);
              } 
              elseif(Mage::registry("complaints_data")) {
                  $form-&gt;setValues(Mage::registry("complaints_data")-&gt;getData());
              }
              return parent::_prepareForm();
               }
              }
  </code></pre>
  
  <p>My model file :  local/Blazedream/VendorComplaints/Model/Complaints.php</p>
  
  <pre><code>        &lt;?php
  
      class Blazedream_VendorComplaints_Model_Complaints extends Mage_Core_Model_Abstract
    {
  protected function _construct(){
  
     $this-&gt;_init("vendorcomplaints/complaints");
  
     }
  
    }
  </code></pre>
  
  <p>local/Blazedream/VendorComplaints/Model/Mysql4/Complaints.php</p>
  
  <pre><code>        &lt;?php
       class Blazedream_VendorComplaints_Model_Mysql4_Complaints extends Mage_Core_Model_Mysql4_Abstract
     {
        protected function _construct()
      {
      $this-&gt;_init("vendorcomplaints/complaints", "vendor_complaints_id");
      }
       } 
  </code></pre>
  
  <p>local/Blazedream/VendorComplaints/Model/Mysql4/Complaints/Collection.php</p>
  
  <pre><code>      &lt;?php
     class Blazedream_VendorComplaints_Model_Mysql4_Complaints_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
  {
  
      public function _construct(){
          $this-&gt;_init("vendorcomplaints/complaints");
      }
  
  
  
  }
  </code></pre>
  
  <p>My sql Setup file:local/Blazedream/VendorComplaints/sql/vendorcomplaints_setup</p>
  
  <pre><code>       &lt;?php
      $installer = $this;
      $installer-&gt;startSetup();
      $sql=&lt;&lt;&lt;SQLTEXT
      create table vendor_complaints(vendor_complaints_id int not null auto_increment,name varchar(1000) not null,order_id varchar(100) NOT NULL,email_id varchar(100) not null,reason text,customer_group varchar(100) not null, primary key(vendor_complaints_id));
          insert into vendor_complaints values(1,'tablename1','3','www@gmail.com','asxasxsx','sadasd');
  
  
      SQLTEXT;
  
      $installer-&gt;run($sql);
  
      $installer-&gt;endSetup();
  </code></pre>
  
  <p>After that i have loaded xml file and view file.. I got the complaint form, but when i enter the details and click on save button I am getting the fatal error.. I dont know where i had done the mistakes..</p>
  
  <p>Can anyone help me to find the issue????</p>