Saving New Forum Option

Gossamer

Active member
So, I'm trying to add a new option to the forum options. It's a radio button select for the new field "forum_type". I've added the new field to the xf_forum table, and I've added the input to the form via template modification.

However, I'm having trouble getting the data to actually save. I've tried the method in this post most recently, after reading about how it can be a bit difficult to extend the actionSave() function.

Here is my DataWriter
PHP:
<?php

class Goss_RoleplaySystem_DataWriter_Forum extends XFCP_Goss_RoleplaySystem_DataWriter_Forum
{
    protected function _getFields()
    {
        $fields = parent::_getFields();
       
        $fields['xf_forum']['forum_type'] = array(
            'type' => self::TYPE_STRING,
            'default' => NULL
        );
       
        return $fields;
    }
   
    protected function _preSave()
    {
        $session = false;
        if (XenForo_Application::isRegistered('session'))
        {
            $session = XenForo_Application::get('session');
        }
       
        if ($session && $session->get('forumType'))
        {
            $this->bulkSet($session->get('forumType'));
           
            $session->remove('forumType');
        }
       
        return parent::_preSave();
    }
}

?>

And here is my ControllerAdmin
PHP:
<?php

class Goss_RoleplaySystem_ControllerAdmin_Forum extends XFCP_Goss_RoleplaySystem_ControllerAdmin_Forum
{
    public function actionSave()
    {
        $session = false;
        if (XenForo_Application::isRegistered('session'))
        {
            $session = XenForo_Application::get('session');
        }
       
        if(!$session)
        {           
            return parent::actionSave();
        }
       
        $forumType = $this->_input->filterSingle('forum_type', XenForo_Input::STRING);
       
        $session->set('forumType', $forumType);
       
        return parent::actionSave();
    }
}

?>
 
Top Bottom