# Adding fields from Profile to the registration form Sometimes you may need to add some fields from Profile to the registration form and this article will help you. ## Override the registration form model Let's start with overriding the registration form model: ```php namespace app\models; use dektrium\user\models\Profile; use dektrium\user\models\RegistrationForm as BaseRegistrationForm; use dektrium\user\models\User; class RegistrationForm extends BaseRegistrationForm { /** * Add a new field * @var string */ public $name; /** * @inheritdoc */ public function rules() { $rules = parent::rules(); $rules[] = ['name', 'required']; $rules[] = ['name', 'string', 'max' => 255]; return $rules; } /** * @inheritdoc */ public function attributeLabels() { $labels = parent::attributeLabels(); $labels['name'] = \Yii::t('user', 'Name'); return $labels; } /** * @inheritdoc */ public function loadAttributes(User $user) { // here is the magic happens $user->setAttributes([ 'email' => $this->email, 'username' => $this->username, 'password' => $this->password, ]); /** @var Profile $profile */ $profile = \Yii::createObject(Profile::className()); $profile->setAttributes([ 'name' => $this->name, ]); $user->setProfile($profile); } } ``` ## Overriding the registration form view Last thing you need to do is overriding the registration form view: ```php title = Yii::t('user', 'Sign up'); $this->params['breadcrumbs'][] = $this->title; ?>
= Html::a(Yii::t('user', 'Already registered? Sign in!'), ['/user/security/login']) ?>