abdfahim
Well-known member
I have added a new group for custom user field with below code
But I am not sure how to override corresponding entries in Entity and Repository. From the XF2 doc, I learned how to add a new entity, but not sure how to change an existing one.
Can anyone please help?
1) In XF\Repository\UserField (required to show the new group in Admin Custom User Field)
2) In XF\Entity\UserField (I am not sure if it is necessary)
Code:
public function installStep1()
{
$this->schemaManager()->alterTable('xf_user_field', function(Alter $table)
{
$table->changeColumn('display_group', 'enum')->values(['personal','contact','preferences','new_custom_field_group']);
});
}
But I am not sure how to override corresponding entries in Entity and Repository. From the XF2 doc, I learned how to add a new entity, but not sure how to change an existing one.
Can anyone please help?
1) In XF\Repository\UserField (required to show the new group in Admin Custom User Field)
PHP:
public function getDisplayGroups()
{
return [
'personal' => \XF::phrase('personal_details'),
'contact' => \XF::phrase('contact_details'),
'preferences' => \XF::phrase('preferences'),
'new_custom_field_group' => \XF::phrase('new_custom_field_group_phrase')
];
}
2) In XF\Entity\UserField (I am not sure if it is necessary)
PHP:
public static function getStructure(Structure $structure)
{
self::setupDefaultStructure(
$structure,
'xf_user_field',
'XF:UserField',
[
'groups' => ['personal', 'contact', 'preferences', 'new_custom_field_group'],
'has_user_editable' => true,
'has_user_editable_once' => true,
'has_moderator_editable' => true
]
);
............................
return $structure;
}
Last edited: