I want to create login and registration forms + User model
Login form should:
-
validate password and login not empty
-
validate that they are match the regular expressions
-
if 1 and 2 are true pass it to UserIdentity for final login, and redirect to member zone
Registration form should:
-
validate password login and email not empty
-
validate email is valid
-
validate that they are match the regular expressions
-
validate the captcha
-
validate that email and username are unique with http://www.yiiframework.com/doc/api/1.1/CUniqueValidator or some custom…
And of course I need User extends CActiveRecord , cause I need some user instance
The options I see:
-
create LoginForm extends CFormModel + RegisterForm extends CFormModel + User extends CActiveRecord
-
create UserForm that extends CFormModel nd work with registration and login by scenario with same model + User that extends CActiveRecord
-
Create only User extends CActiveRecord , and provide it with rules by scenario
What you suggest me?
Actually I like the most - options 2 and 3 , but 2 will make me duplicate a lot of code (mostly the rules)
What I don’t like in CFormModel with the unique validation rule: it requires to set
getDbConnection + tableName , so it is almost ActiveRecord
the downside I see with 3 is - too much scenario in User model will make it a mess…
Also User is an object, and actually it is strange to create new User(‘registration’) just to validate the form etc.