php - Issue facing whille creating form in Admin Panel for Custom Module in Magento CE 1.9.2 -
i developing custom module in facing issue. made custom button on grid . pointing form save data. due issue not coming.
this how added button on grid.
public function getmainbuttonshtml() { $html= parent::getmainbuttonshtml(); $add_button_work = $this->getlayout()->createblock('adminhtml/widget_button') ->setdata(array( "label"=> mage::helper('custom_abc')->__('custom'), "onclick"=> "setlocation('".$this->geturl('*/*/newcustom')."')", "class"=>"save" )); $html .= $add_button_work->tohtml(); return $html; }
here code of controller
public function newcustomaction() { $this->_title($this->__("custom")); $this->_title($this->__("custom")); $this->_title($this->__("new item")); $id = $this->getrequest()->getparam("id"); $model = mage::getmodel("custom_abcd/abc_model")->load($id); $data = mage::getsingleton("adminhtml/session")->getformdata(true); if (!empty($data)) { $model->setdata($data); } mage::register("current_custom", $model); $this->loadlayout(); $this->getlayout()->getblock("head")->setcanloadextjs(true); $this->_addbreadcrumb(mage::helper("adminhtml")->__("custom manager"), mage::helper("adminhtml")->__("custom manager")); $this->_addbreadcrumb(mage::helper("adminhtml")->__("custom manager"), mage::helper("adminhtml")->__("custom manager")); $this->_addcontent($this->getlayout()->createblock("custom_abc/adminhtml_abcd_edit_tab_customize_customform"))->_addleft($this->getlayout()->createblock("custom_abc/adminhtml_abcd_edit_tab_customize_edit_tab_tabs")); $this->renderlayout(); }
my form container code
class custom_abc_block_adminhtml_abcd_edit_tab_customize_customform extends mage_adminhtml_block_widget_form_container { public function __construct() { parent::__construct(); $this->_objectid = "custom_id"; $this->_blockgroup = "custom_abc"; $this->_controller = "adminhtml_abc_custom"; $this->_updatebutton("save", "label", mage::helper("custom _abc")->__("save item")); $this->_updatebutton("delete", "label", mage::helper("custom_abc")->__("delete item")); $this->_addbutton("saveandcontinue", array( "label" => mage::helper("custom_abc")->__("save , continue edit"), "onclick" => "saveandcontinueedit()", "class" => "save", ), -100); $this->_formscripts[] = "function saveandcontinueedit(){ editform.submit($('edit_form').action+'back/edit/'); } "; } public function getheadertext() { if (mage::registry("current_custom") && mage::registry("current_custom")->getid()) { return mage::helper("custom_abc")->__("edit item '%s'", $this->htmlescape(mage::registry("current_custom")->getid())); } else { return mage::helper("custom_abc")->__("add settings"); } } }
my main form here class custom_abc_adminhtml_abcd_edit_tab_customize_edit_tab_customform extends mage_adminhtml_block_widget_form {
protected function _prepareform() { $form = new varien_data_form(); $this->setform($form); $fieldset = $form->addfieldset("custom_form", array("legend" => mage::helper("custom_abc")->__("custom"))); $fieldset->addfield("custom_field1", "varchar", array( "label" => mage::helper('custom_abc')->__("custom field 1"), "name" => "custom_field1", )); $fieldset->addfield("custom_field2", "varchar", array( "label" => mage::helper('custom_abc')->__("custom field 2"), "name" => "custom_field2", )); if (mage::getsingleton("adminhtml/session")->getcustomdata()) { $form->setvalues(mage::getsingleton("adminhtml/session")->getcustomdata()); mage::getsingleton("adminhtml/session")->setcustomdata(null); } elseif (mage::registry("current_custom")) { $form->setvalues(mage::registry("current_custom")->getdata()); } return parent::_prepareform(); }
}
Comments
Post a Comment