Separate user controller and registration controller or combine them?

Building my first web application using Yii and the question is, is it better to include the user registration process as part of my UserController or is it better to create registration control and keep the logic separate?

And ... on the same line of thought, would it be useful to have a profileController to handle additional user information or just have a userController handler too?

+4
source share
5 answers

Is registration the creation of the User?

Similarly, is this a profile, just viewing or updating a user?

It seems that all of them could match one controller well enough, like basic CRUD operations.

0
source

In my opinion, you can switch to UserController , because the concept of registration is the creation of a new user. Therefore, I think you can make Register same as Create .

0
source

Actually, they are not very complex and can be located in one controller. At least my own habit of incorporating CRUD in one controller (maybe my applications are not connected with complex logic)

0
source

Is this form required to enter data that is not permanently stored in dataabse? If so, you should create a new model derived from CFormModel, not ActiveRecord. Your siteโ€™s controller can handle the launch of CFormModel views, which then take care of themselves (validation, ajax, whatever) if they donโ€™t need dynamic interaction with the server (LoginForm), or they can have a separate controller if more complex interaction is necessary (RegisterForm) . In CFormModel, you can access user input during a session and process / save it as you like, but then it disappears when the user is done. See LoginForm and RegisterForm for a demonstration of the blog, for example, templates. Does this form have dynamic data interaction with other models, as well as with the user (and not just a one-time cascade interaction)? In this case, it is best to create a separate separate registrar that you specify. This is what the demo of the blog does, and it is a fairly simple application. You can use gii to automatically create a CRUD interface for administrators and moderators / community managers from your User model. You can then configure it and renderPartial when you want to reuse one of these views for a non-admin user. Validation rules in models carry over too. Only guests and usually privileged users need the disabled LoginForm and RegisterForm interface.

0
source

Itโ€™s a good idea to put custom material in a module so that you can easily use it in another application. In this module, you can place a profile or other user controllers without the clutttering application.

0
source

All Articles