Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

I have an error when create edit form in magento
 
arthur12345543
Jr. Member
 
Total Posts:  2
Joined:  2013-09-19
 

Fatal errorCall to a member function setData() on a non-object in C:\xampp\htdocs\magento3\app\code\core\Mage\Adminhtml\Block\Widget\Form\Container.php on line 129

Edit.php

<?php
    
class Magecom_Magecomslider_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
    {
        
public function __construct()
        
{
            parent
::__construct();
    
            
$this->_objectId 'id';
            
$this->_controller 'adminhtml_magecomslider';
            
$this->_mode 'edit';
    
            
$this->_updateButton('save''label'Mage::helper('magecom_magecomslider')->__('Save Image'));
            
$this->_updateButton('save''id''save_button');
            
$this->_updateButton('delete''label'Mage::helper('magecom_magecomslider')->__('Delete Image'));
    
            if( 
$this->getRequest()->getParam($this->_objectId) ) {
                $magecomSlider 
Mage::getModel('magecom_magecomslider/magecomslider')
                    ->
load($this->getRequest()->getParam($this->_objectId));
                
Mage::register('magecomSlider'$magecomSlider);
            
}
        }
    
        
public function getHeaderText()
        
{
            
return Mage::helper('magecom_magecomslider')->__('Add Image');
        
}
    }

Form.php

<?
    
class Mage_Adminhtml_Block_Magecom_Magecomslider_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
    {
        
protected function _prepareForm()
        
{exit("asd");exit("asd");
            
$magecomSlider Mage::registry('magecomSlider');
            
//$product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
            //$customer = Mage::getModel('customer/customer')->load($review->getCustomerId());
            
$magecomslider Mage::getModel('magecom_magecomslider/magecomslider')->load($this->getRequest()->getParam('id'));
            
            
$form = new Varien_Data_Form(array(
                
'id'        => 'edit_form',
                
'action'    => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'ret' => Mage::registry('ret'))),
                
'method'    => 'post'
            
));
    
            
$fieldset $form->addFieldset('magecomslider', array('legend' => Mage::helper('magecom_magecomslider')->__('Add Image'), 'class' => 'fieldset-wide'));
    
            
$fieldset->addField('magecomslider''image', array(
                
'label'     => Mage::helper('magecom_magecomslider')->__('Image'),
                
'text'      => 'magecomslider',
            ));
    
            
$form->setUseContainer(true);
            
$form->setValues($review->getData());
            
$this->setForm($form);
            return 
parent::_prepareForm();
        
}
    }

MagecomsliderController.php

<?php
    
class Magecom_Magecomslider_Adminhtml_MagecomsliderController extends Mage_Adminhtml_Controller_Action
    {
      
public function editAction()
        
{
            $this
->loadLayout();
            
$product_id $this->getRequest()->getParam('id');
            
            
$slider_items Mage::getModel('magecom_magecomslider/magecomslider');
            
$collection_slider_items $slider_items->getCollection();
            
$collection_slider_items_count $collection_slider_items->count();
            if(
$collection_slider_items_count==2)
            
{
                
            }else{
                $this
->_getSession()->addError($this->__('Please select products for slider.'));
            
}
            $this
->renderLayout();
            
//exit($product_id);
        
}
}

magecomslider.xml

<?xml version="1.0"?>
    
<layout version="0.1.0">
        <
adminhtml_magecomslider_index>
            <
reference name="content">
                <
block type="magecom_magecomslider/adminhtml_magecomslider" name="magecomslider.grid_container" />
            </
reference>
        </
adminhtml_magecomslider_index>
    
        <
adminhtml_magecomslider_new>
            <
update handle="adminhtml_magecomslider_edit"/>
        </
adminhtml_magecomslider_new>
    
        <
adminhtml_magecomslider_edit>
            <
reference name="content">
                <
block type="magecom_magecomslider/adminhtml_edit" name="magecomslider.edit" />
            </
reference>
        </
adminhtml_magecomslider_edit>
        <
adminhtml_magecomslider_grid>
            <
block type="core/text_list" name="root" output="toHtml">
                <
block type="magecom_magecomslider/adminhtml_magecomslider" name="magecomslider.grid_container" />
            </
block>
        </
adminhtml_magecomslider_grid>
        <
adminhtml_magecomslider_edit>
            <
reference name="content">
                <
block type="magecom_magecomslider/adminhtml_edit" name="magecomslider.form_container" />
            </
reference>
        </
adminhtml_magecomslider_edit>
    </
layout>

Helo me please!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top