Search Results

Search found 2 results on 1 pages for 'shani1351'.

Page 1/1 | 1 

  • Magento - edit form in custom module grid

    - by Shani1351
    I have a custom module and I have a working grid to menage the module items in the admin. My module file structore is : app\code\local\G4R\GroupSales\Block\Adminhtml\Groupsale\ I want to add an edit form so I can view and edit each item in the grid. I followed this tutorial : http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table#part_2_-_backend_administration but when the edit page loads, instead of the tab content I get an error : Fatal error: Call to a member function setData() on a non-object in C:\xampp\htdocs\mystore\app\code\core\Mage\Adminhtml\Block\Widget\Form\Container.php on line 129 This is my code : /app/code/local/G4R/GroupSales/Block/Adminhtml/Groupsale/Edit.php <?php class G4R_GroupSales_Block_Adminhtml_Groupsale_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { parent::__construct(); $this->_objectId = 'id'; $this->_blockGroup = 'groupsale'; $this->_controller = 'adminhtml_groupsales'; $this->_updateButton('save', 'label', Mage::helper('groupsales')->__('Save Item')); $this->_updateButton('delete', 'label', Mage::helper('groupsales')->__('Delete Item')); } public function getHeaderText() { if( Mage::registry('groupsale_data') && Mage::registry('groupsale_data')->getId() ) { return Mage::helper('groupsales')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('groupsale_data')->getTitle())); } else { return Mage::helper('groupsales')->__('Add Item'); } } } /app/code/local/G4R/GroupSales/Block/Adminhtml/Groupsale/Edit/Form.php : <?php class G4R_GroupSales_Block_Adminhtml_Groupsale_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', ) ); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); } } /app/code/local/G4R/GroupSales/Block/Adminhtml/Groupsale/Edit/Tabs.php: <?php class G4R_GroupSales_Block_Adminhtml_Groupsale_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { public function __construct() { parent::__construct(); $this->setId('groupsales_groupsale_tabs'); $this->setDestElementId('edit_form'); $this->setTitle(Mage::helper('groupsales')->__('Groupsale Information')); } protected function _beforeToHtml() { $this->addTab('form_section', array( 'label' => Mage::helper('groupsales')->__('Item Information 1'), 'title' => Mage::helper('groupsales')->__('Item Information 2'), 'content' => $this->getLayout()->createBlock('groupsales/adminhtml_groupsale_edit_tab_form')->toHtml(), )); return parent::_beforeToHtml(); } } /app/code/local/G4R/GroupSales/Block/Adminhtml/Groupsale/Edit/Tab/Form.php : <?php class G4R_GroupSales_Block_Adminhtml_Groupsale_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form { protected function _prepareForm() { $form = new Varien_Data_Form(); $this->setForm($form); $fieldset = $form->addFieldset('groupsales_form', array('legend'=>Mage::helper('groupsales')->__('Item information 3'))); // $fieldset->addField('title', 'text', array( // 'label' => Mage::helper('groupsales')->__('Title'), // 'class' => 'required-entry', // 'required' => true, // 'name' => 'title', // )); // if ( Mage::getSingleton('adminhtml/session')->getGroupsaleData() ) { $form->setValues(Mage::getSingleton('adminhtml/session')->getGroupsaleData()); Mage::getSingleton('adminhtml/session')->setGroupsaleData(null); } elseif ( Mage::registry('groupsale_data') ) { $form->setValues(Mage::registry('groupsale_data')->getData()); } return parent::_prepareForm(); } } /app/code/local/G4R/GroupSales/controllers/Adminhtml/GroupsaleController.php : <?php class G4R_GroupSales_Adminhtml_GroupsaleController extends Mage_Adminhtml_Controller_Action { protected function _initAction() { $this->loadLayout() ->_setActiveMenu('groupsale/items') ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager')); return $this; } public function indexAction() { $this->_initAction(); $this->_addContent($this->getLayout()->createBlock('groupsales/adminhtml_groupsale')); $this->renderLayout(); } public function editAction() { $groupsaleId = $this->getRequest()->getParam('id'); $groupsaleModel = Mage::getModel('groupsales/groupsale')->load($groupsaleId); if ($groupsaleModel->getId() || $groupsaleId == 0) { Mage::register('groupsale_data', $groupsaleModel); $this->loadLayout(); $this->_setActiveMenu('groupsale/items'); $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager')); $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News')); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $this->_addContent($this->getLayout()->createBlock('groupsales/adminhtml_groupsale_edit')) ->_addLeft($this->getLayout()->createBlock('groupsales/adminhtml_groupsale_edit_tabs')); $this->renderLayout(); } else { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('groupsales')->__('Item does not exist')); $this->_redirect('*/*/'); } } public function newAction() { $this->_forward('edit'); } public function saveAction() { if ( $this->getRequest()->getPost() ) { try { $postData = $this->getRequest()->getPost(); $groupsaleModel = Mage::getModel('groupsales/groupsale'); $groupsaleModel->setId($this->getRequest()->getParam('id')) ->setTitle($postData['title']) ->setContent($postData['content']) ->setStatus($postData['status']) ->save(); Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved')); Mage::getSingleton('adminhtml/session')->setGroupsaleData(false); $this->_redirect('*/*/'); return; } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); Mage::getSingleton('adminhtml/session')->setGroupsaleData($this->getRequest()->getPost()); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); return; } } $this->_redirect('*/*/'); } public function deleteAction() { if( $this->getRequest()->getParam('id') > 0 ) { try { $groupsaleModel = Mage::getModel('groupsales/groupsale'); $groupsaleModel->setId($this->getRequest()->getParam('id')) ->delete(); Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted')); $this->_redirect('*/*/'); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); } } $this->_redirect('*/*/'); } /** * Product grid for AJAX request. * Sort and filter result for example. */ public function gridAction() { $this->loadLayout(); $this->getResponse()->setBody( $this->getLayout()->createBlock('importedit/adminhtml_groupsales_grid')->toHtml() ); } } Any ideas what is the cause for the error?

    Read the article

  • invite friends in a dialog in a Facebook application

    - by Shani1351
    I'm trying to create a Facebook application that displays a friend invite dialog within the application using Facebook's Javascript API (FB.ui). To do that I followed this tutorial I have two problems : The action url I've put in the request-form is "http://apps.facebook.com/appname/post_invite.php" but I see that the iframe source after the post is "http://mydomain.com/post_invite.php" and when this iframe tries to do : parent.closeInviteWidget(); I get an error saying : "Permission denied for < http: //mydomain.com (document.domain has not been set) to get property Window.closeInviteWidget from < http:// apps.facebook.com (document.domain=< http:// facebook.com)." The skip button inside the request-form opens the action url in a new window (new browser tab) and not post to itself like the invite button. How can I fix those problems? -------------------- UPDATE : -------------------------------- I've tried to do what ifaour said and changed the code to : function inviteFriends(user_name, category_id, category_name) { url = appBaseUrl + "/index.php?category_id=" + category_id; req = "<fb:req-choice url='" + url + "' label='Authorize My Application' />"; content = user_name + " opened a new category called " + category_name + ". " + req; action = 'post_invite.php'; fbmi_text = '<fb:request-form action="' + action + '" target="_self" method="post" invite="true" type="Invite" content="' + content + '" <fb:multi-friend-selector showborder="false" actiontext="Invite yor friends" email_invite="false" import_external_friends="false" /> </fb:request-form>'; FB.ui({ method:'fbml.dialog', width:'750px', fbml:fbmi_text }); } When I use FireBug and look at the invite form it looks like this: <form id="req_form_4d20682f73ddb6e71722794" content="I've opened a new category called dsfsd. <fb:req-choice url='http://apps.facebook.com/appname/index.php?category_id=60' label='Authorize My Application' /> type="Invite" invite="true" method="post" target="_self" action="http://apps.facebook.com/appname/post_invite.php"> ... </form> But I still get the same error : Permission denied for <http://mydomain.com> (document.domain has not been set) to get property Window.closeInviteWidget from <http://apps.facebook.com> (document.domain=<http://facebook.com>)...

    Read the article

1