Welcome Guest, Not a member yet? Register   Sign In
Shield add firstname , lastname to users table
#1

hi , as documentation to add field  :
  • change view in config with file in app/view 
  • add new fields (firstname,lastname) to registration form
  • create migration add firstname,lastname in db
  • in config/validation copied the validation and add firstname and lastname rules
Try to register ,validation working fine but firstname and lastname aren't stored in db . 

What step i missing ?
Reply
#2

Create your own UserModel.
See https://codeigniter4.github.io/shield/cu..._to_users/
Reply
#3

(12-06-2023, 06:20 PM)kenjis Wrote: Create your own UserModel.
See https://codeigniter4.github.io/shield/cu..._to_users/

hi , sorry i dont wrote it :

Code:
<?php

declare(strict_types=1);

namespace App\Models;

use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;

class UserModel extends ShieldUserModel
{
    protected function initialize(): void
    {
        parent::initialize();

        $this->allowedFields = [
           
            'firstname',
            'lastname',
        ];
    }
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB