1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem extending XenForo_ControllerAdmin_Forum.

Discussion in 'XenForo Development Discussions' started by Jake B., Jan 5, 2014.

  1. Jake B.

    Jake B. Well-Known Member

    I am having issues extending the actionSave function in the XenForo_ControllerAdmin_Forum controller.

    Here is what I have:

    Code:
    <?php
    class Dev_AddonName_ControllerAdmin_Forum extends XFCP_Dev_AddonName_ControllerAdmin_Forum
    {
    
        public function actionSave()
        {
            //$this->_assertPostOnly();
            return parent::actionSave();
        }
    }
    Also, I extended actionEdit, and it works perfectly fine. actionSave throws this error when I try to save the forum:

     
  2. Lawrence

    Lawrence Well-Known Member

    As you are extending actionSave(), maybe the controller is looking for a response from actionValidateField as well? For example, the code I use for actionSave and actionValidateField from my IcewindDaleRP_IcewindDale_ControllerAdmin_Forum class:

    PHP:
        public function actionSave()
        {
            
    $response parent::actionSave();
            if (
    $response->redirectType == XenForo_ControllerResponse_Redirect::SUCCESS)
            {
                
    $xpmData $this->_input->filter(array(
                    
    'node_id' => XenForo_Input::UINT,
                    
    'xp_mod' => XenForo_Input::UINT,
                    
    'gold_mod' => XenForo_Input::UINT,
                    
    'encounter' => XenForo_Input::UINT,
                    
    'trap' => XenForo_Input::UINT,
                    
    'treasure' => XenForo_Input::UINT
                
    ));
               
                if (empty(
    $xpmData['node_id']))
                {
                    
    $xpmData['node_id'] = $this->_getLastSavedForumNodeId();
                }
       
                
    $dw XenForo_DataWriter::create('IcewindDaleRP_IcewindDale_DataWriter_Forum');
               
                
    $xpmOptionsModel $this->_getForumXpModOptionsModel();
                if (
    $xpmOptionsModel->verifyForumXpModId($xpmData['node_id']))
                {
                    
    $dw->setExistingData($xpmData['node_id']);
                }

                
    $dw->bulkSet($xpmData);
                
    $dw->save();
               
                
    $xpmOptionsModel->rebuildForumXpModCache();
            }
            return 
    $response;
        }
    PHP:
        public function actionValidateField()
        {
            
    $parentResponse parent::actionValidateField();

            
    $fieldName $this->_input->filterSingle('name'XenForo_Input::STRING);
            if (
    $fieldName == 'xp_mod' OR $fieldName == 'gold_mod')
            {
                
    $xpmResponse $this->_validateField('IcewindDaleRP_IcewindDale_DataWriter_Forum', array(
                    
    'existingDataKey' => $this->_input->filterSingle('node_id'XenForo_Input::UINT))
                );
                return 
    $xpmResponse;
            }
            else
            {
                return 
    $parentResponse;
            }
        }
    The above works as expected. Hope it helps, :)
     
  3. Jake B.

    Jake B. Well-Known Member

    It actually ended up being a problem with my extended DataWriter. Kind of odd that it would throw that, but it works now.
     

Share This Page