I had a problem. What would be the best solution in this case:
I have a User model that extends CActiveRecord. It consist of ID, Username, Password and Status fields. In creating this model [Registration process], I prefer to have a form with 2 password fields. These 2 fields will be check whether they are the same or not. Only providing one field is not wise since user may make mistakes in typing. The solution what I can think of is making a RegistrationForm extends CFormModel that consist of ID, Username, Password1 and Password2. By having this, I can validate the Password1 = Password2. Is it possible to make the RegistrationForm extends CFormModel to have User and Password2 as the fields/ How could I access this on the view?
Also note the scenario ‘register’. You can add that scenario to all fields you want to use in your registration form. Then set that scenario when you create your model so that all other fields are considered “unsafe”.
You can use the same model for different forms. With a scenario you can define, which model attributes can be assigned in which situation (a.k.a. scenario). So e.g. you could use a model User for registration and for login. These are 2 scenarios. On registration a lot of attributes should be assignable (a.k.a. "be safe") whereas on login only username, password and repeatPassword should be considered "safe".