I have a form that saved the value in DB and then i have retrieve that values in an admin Grid Now on Grid view i have Edit button that suppose to be take the user to edit form and after some changes save the edit form. But in my case it showing empty forms.
I have Controller function for edit action is as like follows:
public function editAction() { $this->_registryObject(); $this->getResponse()->setBody( $this->getLayout()->createBlock('optfirst_reviewmycompany/adminhtml_edits_edit') ->toHtml() ); }
Here is the Edit.php code
public function __construct() { parent::__construct(); $this->_blockGroup = 'optfirst_reviewmycompany'; $this->_controller = 'adminhtml_edits'; $this->_headerText = Mage::helper('optfirst_reviewmycompany')->__('Social Icons'); }
And this is my Edit action from my Grid:
public function __construct() { $this->_controller = 'adminhtml_review'; $this->_blockGroup = 'optfirst_reviewmycompany'; $this->_headerText = Mage::helper('optfirst_reviewmycompany')->__('Social Icon Manager'); $this->_addButton('add_new', array( 'label' => Mage::helper('optfirst_reviewmycompany')->__('Edit Social Icons'), 'onclick' => "setLocation('{$this->getUrl('/adminform/edit')}')", 'class' => 'edit' )); parent::__construct(); }
And here is the form.php code that have to show the edit input fields:
protected function _prepareForm() { $form = new Varien_Data_Form(array( 'id' => 'edit_form', 'action' => $this->getUrl('*/*/edit'), 'method' => 'post', )); $form->setUseContainer(true); $this->setForm($form); $helper = Mage::helper('optfirst_reviewmycompany'); $fieldset = $form->addFieldset('display', array('legend' => $helper->__('Select Social Icons'), 'class' => 'fieldset-wide')); $fieldset->addField('google', 'text', array( 'name' => 'google', 'label' => $helper->__('Google'), )); $fieldset->addField('twitter', 'text', array( 'name' => 'twitter', 'label' => $helper->__('Twitter'), )); $fieldset->addField('yelp', 'text', array( 'name' => 'yelp', 'label' => $helper->__('Yelp'), )); $fieldset->addField('linkedin', 'text', array( 'name' => 'linkedin', 'label' => $helper->__('LinkedIn'), )); $fieldset->addField('pintrest', 'text', array( 'name' => 'pintrest', 'label' => $helper->__('Pintrest'), )); $fieldset->addField('gmaps', 'text', array( 'name' => 'gmaps', 'label' => $helper->__('Google Map'), )); $fieldset->addField('bing', 'text', array( 'name' => 'bing', 'label' => $helper->__('Bing'), )); $fieldset->addField('coc', 'text', array( 'name' => 'coc', 'label' => $helper->__('Chamber of Commerce'), )); $fieldset->addField('city_search', 'text', array( 'name' => 'city_search', 'label' => $helper->__('City Search'), )); $fieldset->addField('ezlocal', 'text', array( 'name' => 'ezlocal', 'label' => $helper->__('EZLocal'), )); $fieldset->addField('local', 'text', array( 'name' => 'local', 'label' => $helper->__('Local'), )); $fieldset->addField('mcircle', 'text', array( 'name' => 'mcircle', 'label' => $helper->__('MerchantCircle'), )); $fieldset->addField('show_me_local', 'text', array( 'name' => 'show_me_local', 'label' => $helper->__('ShowmeLocal'), )); $fieldset->addField('superpages', 'text', array( 'name' => 'superpages', 'label' => $helper->__('Superpages'), )); $fieldset->addField('topix', 'text', array( 'name' => 'topix', 'label' => $helper->__('Topix'), )); $fieldset->addField('uscity', 'text', array( 'name' => 'uscity', 'label' => $helper->__('USCity'), )); $fieldset->addField('where_to_app', 'text', array( 'name' => 'where_to_app', 'label' => $helper->__('Wheretoapp'), )); $fieldset->addField('yahoo', 'text', array( 'name' => 'yahoo', 'label' => $helper->__('Yahoo'), )); $fieldset->addField('yellow_bot', 'text', array( 'name' => 'yellow_bot', 'label' => $helper->__('Yellowbot'), )); $fieldset->addField('yellow_wise', 'text', array( 'name' => 'yellow_wise', 'label' => $helper->__('Yellowise'), )); if (Mage::registry('optfirst_reviewmycompany')) { $form->setValues(Mage::registry('optfirst_reviewmycompany')->getData()); } return parent::_prepareForm(); } }
And showing the edit form like the image attached not proper layout.
Hi @Shoaib_Fareedi,
Your edit action has this code:
$this->_registryObject();
Can you share the content of the method?
add this function in your grid and check
public function getRowUrl($row) { return $this->getUrl('*/*/edit', array('id' => $row->getId())); }