yii2-usuario icon indicating copy to clipboard operation
yii2-usuario copied to clipboard

Add a custom field to profile

Open skiiiks opened this issue 6 years ago • 1 comments

I'd like to add a custom field to profile (well, indeed, several ;-) I wonder if the good way to do is to "override" profile model. Should I modify the "profile" table first ? I mean, I create a new column in the MySQL profile table called "gender".

Then the good way would be ... ?

common\models\Profile.php

<?php
namespace common\models;
use Da\User\Model\Profile as BaseProfile;

class Profile extends BaseProfile
{
    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'gender' => Yii::t('usuario', 'Gender'),
        ];
    }      
}

And in the containers definition:

'container' => [
    'definitions' => [
        Da\User\Model\Profile::class => common\models\Profile::class,
    ],
],

This is it ? So simple ? I mean, I've tested and it's working but I wonder if that's the best way to do with yii2-usuario

skiiiks avatar Jul 30 '19 16:07 skiiiks

@skiiiks is good

tonydspaniard avatar Aug 25 '19 13:08 tonydspaniard