user registration and profile types

Hi all,

I’m new to this board and thought I’d start by submitting a question. I started using yii a few weeks ago for this web service am developing. The application requires users to register/create account like many applications.But in the early stages of the development am limiting the user types to three students,teachers,and artists, depending on their roles in the application.

I created tables in database, tbl_student , tbl_teacher , tbl_artist and tbl_profile. And I was thinking when a user registers by choosing a role then the page he views is in accordance with the role he chose.This will be done when the user is logged in to the system.

Now my question is how do I let users choose their role upon registration? Since there are three different pages assigned to each of them accordingly.

Thanks in advance.

For your user/role system, I suggest you to read this wiki article

This would maybe gives you a better table structure:

tbl_user => user credentials + user role

tbl_student => all the details of the student profile (with a field "user_id")

tbl_teatcher => idem

tbl_artist => idem

use the relations in your models declarations:

  • model User: has_many "Student", related field: user_id; has_many "teatchers" and so on

  • model Student: belongs_to "User", related field: user_id;

  • model Teatcher: belongs_to "User" …

Now if I well understand your question, you need three different kind of registration forms.

You can use in your create form view a dropdown (see wiki above) with an ajax "onChange" action (createStudent, createTeatcher, createArtist) wich will update a <div id="registrationForm">. Each of these controller actions will create the new $model ($model = new Student;) and then call a renderPartial (_createStudent for example) that will update the div with id registrationForm.

Thanks for a quick reply luc.

I’ll make the changes in my database.And javascript is ideal for the registration forms since I needed it to be on the same page without reloading it. Thanks