How to Get Another Model ID

In the projects that I work on, user models and employees are related 1…1,
I want to create an employee profile from the active user. I am confused about how to make employee IDs and user IDs fill in by themselves, without being manually inputted.

Hi Rosafresia,

Firstly welcome to Yii Community Forum!

Your questions are bit general, could you share some snippets so that the community members can predict what actually your issue or struggle is?

From my understanding, I can say that you can use afterSave() function in your user model to create employee profile dynamically. and what are the data you will feed for the employee table? from where you’ll get it? if you are getting the data from same form from user for both tables then using afterSave() is the best method to implement your target.

for more info read here https://www.yiiframework.com/doc/api/2.0/yii-db-baseactiverecord#afterSave()-detail