Hi,
I'm writing my first xenForo add-on. The goal is to display an additional checkbox in the user account preferences and store its value in a new column in xf_user_option. Displaying the checkbox and making it use the value from the database is already working. But writing the checkbox value to the database does not work.
Which kind of class extension do I need and which method do I need to override? My latest attempt was this:
With this the value is not written to the database. What am I missing?
I'm writing my first xenForo add-on. The goal is to display an additional checkbox in the user account preferences and store its value in a new column in xf_user_option. Displaying the checkbox and making it use the value from the database is already working. But writing the checkbox value to the database does not work.
Which kind of class extension do I need and which method do I need to override? My latest attempt was this:
Code:
namespace My\AddOn\XF\Pub\Controller;
use XF\Entity\User;
/**
* Extends \XF\Pub\Controller\Account
*/
class Account extends XFCP_Account
{
/**
* @param User $visitor
* @return \XF\Mvc\FormAction
*/
protected function preferencesSaveProcess(User $visitor)
{
$form = parent::preferencesSaveProcess($visitor);
$input = $this->filter([
'option' => [
'mycolumn' => 'bool',
],
]);
$userOptions = $visitor->getRelationOrDefault('Option');
$form->setupEntityInput($userOptions, $input['option']);
return $form;
}
}
With this the value is not written to the database. What am I missing?