Problem extending XenForo_ControllerAdmin_Forum.

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:

No controller response from XenForo_ControllerAdmin_Forum::actionSave
  1. XenForo_FrontController->_handleControllerResponse() inE:\xampp\htdocs\xenStop\library\XenForo\FrontController.php at line 355
  2. XenForo_FrontController->dispatch() in E:\xampp\htdocs\xenStop\library\XenForo\FrontController.php at line 134
  3. XenForo_FrontController->run() in E:\xampp\htdocs\xenStop\admin.php at line 13
 
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, :)
 
It actually ended up being a problem with my extended DataWriter. Kind of odd that it would throw that, but it works now.
 
Top Bottom