BoostN
Well-known member
I've added a new field to the xf_user table. I've extended the following class:
XF\Admin\Controller\User
to BoostN\AppName\XF\Admin\Controller\User
My Listener:
Code Event Listener:
Listen to Event: entity_structure
Callback: BoostN\AppName\Listener Method: userEntityStructure
I'm wanting to do this for the AdminCP View only. If I populate the column in the DB with text, it shows up fine, I'm just unable to save the modified values via the form.
When saving:
I found this post by Mike, and tried that but no luck either. And perhaps I just didn't understand..
XF\Admin\Controller\User
to BoostN\AppName\XF\Admin\Controller\User
PHP:
<?php
namespace BoostN\AppName\XF\Admin\Controller;
class User extends XFCP_User
{
protected function userSaveProcess(\XF\Entity\User $user)
{
parent::userSaveProcess($user);
$form = $this->formAction();
$input = $this->filter([
'user' => [
'my_column' => 'str'
]
]);
//return $form->basicEntitySave($user, $input['user']); //This worked at first, but only this field would save.
return $form->setupEntityInput($user, $input['user']);
}
}
My Listener:
PHP:
<?php
namespace BoostN\AppName;
use XF\Mvc\Entity\Entity;
class Listener
{
public static function userEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
{
$structure->columns['my_column'] = ['type' => Entity::STR, 'default' => null];
}
}
Code Event Listener:
Listen to Event: entity_structure
Callback: BoostN\AppName\Listener Method: userEntityStructure
I'm wanting to do this for the AdminCP View only. If I populate the column in the DB with text, it shows up fine, I'm just unable to save the modified values via the form.
When saving:
Code:
XF\Db\Exception: MySQL statement prepare error [1054]: Unknown column 'my_column' in 'field list' src\XF\Db\AbstractStatement.php:183
I found this post by Mike, and tried that but no luck either. And perhaps I just didn't understand..
Last edited: