0
我已向用戶模型「paypal」添加了一個新字段,並且需要將其重寫爲覆蓋的帳戶表單。Yii2 dektrium爲用戶模型添加新字段並以賬戶形式更改
替代用戶模型
<?php
namespace common\models;
class User extends \dektrium\user\models\User
{
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['create'][] = 'paypal';
$scenarios['update'][] = 'paypal';
$scenarios['register'][] = 'paypal';
return $scenarios;
}
public function rules()
{
$rules = parent::rules();
$rules['paypalLength'] = ['paypal', 'string', 'max' => 255];
return $rules;
}
}
覆蓋SettingsForm模型
<?php
namespace common\models;
class SettingsForm extends \dektrium\user\models\SettingsForm
{
public $paypal;
public function rules()
{
$rules = parent::rules();
$rules['paypalLength'] = ['paypal', 'string', 'max' => 255];
return $rules;
}
}
配置模塊
'user' => [
'class' => 'dektrium\user\Module',
'modelMap' => [
'User' => 'common\models\User',
'RegistrationForm' => 'common\models\RegistrationForm',
'SettingsForm' => 'common\models\SettingsForm',
],
'controllerMap' => [
...
我已重寫帳戶表格圖。當我嘗試更改用戶/設置/帳戶中的paypal字段時,它不會更改它。我應該怎麼做才能使它工作? 謝謝。你