I’m using yii2-usuario and am trying to save mobile to database
$user = User::findOne(Yii::$app->user->identity->id);
$user->scenario = 'update';
if (Yii::$app->request->isPost && $user->load(Yii::$app->request->post())) {
if($user->validate()) {
$user->mobile = $_POST['User']['mobile'];
if (!$user->save(false)) {
Yii::$app->response->format = 'json';
print_r($user->getErrors()); die;
}
in my user model i have this
class User extends BaseUser
{
public $mobile;
...
}
in user
model i’ve added these to the rules too
'mobileLength' => ['mobile', 'string', 'max' => 11],
Any idea why? What am i missing here?