No data received - editAction Magento
-
13-12-2019 - |
Question
I have setup a module which includes a menu and grid in the backend to edit the entities. The index url, showing the grid overview of all of the entities works, but the new/edit actions are not working. I am receiving No data received (ERR_EMTPY_RESPONSE). I have tried clearing cache and different browsers, but neither have helped.
Here is the backend related code: Controller index/new/edit actions:
class Badia_Siteseo_Adminhtml_SellingpointController extends Mage_Adminhtml_Controller_Action
{
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('websitedesign/sellingpoint')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Unique selling points'), Mage::helper('adminhtml')->__('Unique selling points'));
return $this;
}
public function indexAction()
{
$this->_initAction()
->renderLayout();
}
public function newAction(){
$this->_forward('edit');
}
public function editAction()
{
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('badia_siteseo/sellingpoint')->load($id);
if ($model->getId() || $id == 0){
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if (!empty($data)){
$model->setData($data);
}
Mage::register('sellingpoint_data', $model);
$this->loadLayout();
$this->_setActiveMenu('websitedesign/sellingpoint');
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Website design'), Mage::helper('adminhtml')->__('Webside design'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Unique selling point'), Mage::helper('adminhtml')->__('Unique selling point'));
$this->_addContent($this->getLayout()->createBlock('badia_siteseo/adminhtml_sellingpoint_edit'))
->_addLeft($this->getLayout()->createBlock('badia_siteseo/adminhtml_sellingpoint_edit_tabs'));
$this->renderLayout();
}else{
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('badia_siteseo')->__('Unique selling point does not exist'));
$this->_redirect('*/*/');
}
}
}
config.xml:
<config>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Badia_Siteseo before="Mage_Adminhtml">Badia_Siteseo_Adminhtml</Badia_Siteseo>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<badia_siteseo>
<file>badia_siteseo.xml</file>
</badia_siteseo>
</updates>
</layout>
</adminhtml>
</config>
badia_siteseo.xml:
<?xml version="1.0"?>
<layout version="0.0.1">
<adminhtml_sellingpoint_index>
<reference name="content">
<block type="badia_siteseo/adminhtml_sellingpoint" name="sellingpoint_grid" />
</reference>
</adminhtml_sellingpoint_index>
</layout>
Block_Adminhtml_Sellingpoint:
<?php
class Badia_Siteseo_Block_Adminhtml_Sellingpoint extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'adminhtml_sellingpoint';
$this->_blockGroup = 'badia_siteseo';
$this->_headerText = Mage::helper('badia_siteseo/sellingpoint')->__('Unique selling points');
$this->_addButtonLabel = Mage::helper('badia_siteseo/sellingpoint')->__('Add unique selling point');
parent::__construct();
}
}
Block_Adminhtml_Sellingpoint_Grid:
<?php
class Badia_Siteseo_Block_Adminhtml_Sellingpoint_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('id');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$collection = Mage::getModel('badia_siteseo/sellingpoint')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
public function getRowUrl($row)
{
return $this->getUrl(
'adminhtml/sellingpoint/edit',
array('id' => $row->getId())
);
}
protected function _prepareColumns()
{
$this->addColumn('id', array(
'header' => $this->translate('Id'),
'type' => 'number',
'index' => 'id',
));
$this->addColumn('title', array(
'header' => $this->translate('Title'),
'type' => 'text',
'index' => 'title'
));
$this->addColumn('description', array(
'header' => $this->translate('Description'),
'type' => 'text',
'index' => 'description'
));
$this->addColumn('status', array(
'header' => $this->translate('Status'),
'type' => 'options',
'index' => 'status',
'options' => $this->getEnabledStatuses(),
));
$this->addColumn('sortOrder', array(
'header' => $this->translate('Sort order'),
'type' => 'number',
'index' => 'sortOrder',
));
$this->addColumn('modifiedBy', array(
'header' => $this->translate('Modified by'),
'type' => 'text',
'index' => 'modifiedBy',
));
$this->addColumn('modifiedDateTime', array(
'header' => $this->translate('Modified date and time'),
'type' => 'datetime',
'index' => 'modifiedDateTime',
));
$this->addColumn('action', array(
'header' => $this->translate('Action'),
'width' => '50px',
'type' => 'action',
'actions' => array(
array(
'caption' => $this->translate('Edit'),
'url' => array(
'base' => 'adminhtml/sellingpoint/edit',
),
'field' => 'id'
),
),
'filter' => false,
'sortable' => false,
'index' => 'id',
));
}
public function translate($args)
{
return Mage::helper('badia_siteseo/sellingpoint')->__($args);
}
private function getEnabledStatuses()
{
return Mage::getSingleton('badia_siteseo/sellingpoint')->getEnabledStatuses();
}
}
Block_Adminhtml_Sellingpoint_Edit:
<?php
class Badia_Siteseo_Block_Adminhtml_Sellingpoint_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
protected function _construct()
{
parent::__construct();
$this->_objectId = 'id';
$this->_blockGroup = 'badia_siteseo';
$this->_controller = 'adminhtml_sellingpoint';
$this->_updateButton('save', 'label', Mage::helper('badia_siteseo/sellingpoint')->__('Save unique selling point'));
$this->_updateButton('delete', 'label', Mage::helper('badia_siteseo/sellingpoint')->__('Delete unique selling point'));
$this->_addButton('saveandcontinue', array(
'label' => Mage::helper('adminhtml')->__('Save and continue edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save',
), -100);
$this->_formScripts[] = "
function saveAndContinueEdit(){
editForm.submit($('edit_form').action+'back/edit/');
}
";
}
public function getHeaderText()
{
$newOrEdit = $this->getRequest()->getParam('id')
? $this->__('Edit')
: $this->__('New');
return $newOrEdit . ' ' . $this->__('Unique Selling Point');
}
}
Block_Adminhtml_Sellingpoint_Edit_Form:
class Badia_Siteseo_Block_Adminhtml_Sellingpoint_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$form = new Varien_Data_Form(array(
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save',
array('id' => $this->getRequest()->getParam('id'))),
'method' => 'post',
'enctype' => 'multipart/form-data'
)
);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
Block_Adminhtml_Sellingpoint_Edit_Tabs:
class Badia_Siteseo_Block_Adminhtml_Sellingpoint_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{
public function __construct()
{
parent::__construct();
$this->setId('sellingpoint_tabs');
$this->setDestElementId('edit_form');
$this->setTitle(Mage::helper('badia_sitesoe/sellingpoint')->__('Selling point'));
}
protected function _beforeToHtml()
{
$this->addTab('form_section', array(
'label' => Mage::helper('badia_sitesoe/sellingpoint')->__('Selling point information'),
'title' => Mage::helper('badia_sitesoe/sellingpoint')->__('Selling point information'),
'content' => $this->getLayout()->createBlock('badia_siteseo/adminhtml_sellingpoint_edit_tab_form')->toHtml(),
));
return parent::_beforeToHtml();
}
}
Block_Adminhtml_Sellingpoint_Edit_Tab_Form: This is not done yet, but I do not think that that would be reason that I am getting this error.
class Badia_Siteseo_Block_Adminhtml_Sellingpoint_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
protected function _prepareForm() {
$form = new Varien_Data_Form();
$this->setForm($form);
$dataObj = new Varien_Object(
array(
'store_id' => '',
'name_in_store' => '',
'status_in_store' => '',
'click_url_in_store' => '',
)
);
return parent::_prepareForm();
}
Solution
Turns out that in the class Badia_Siteseo_Block_Adminhtml_Sellingpoint_Edit, the constructor method was protected instead of public.