I have two models - > users and userPersons. The first one responds for the table users, which has standard fields like email, password.
In the second model I have fields specific for the Persons type of registration. I am using the following type to validate EMAIL and PASSWORD:
public function rules()
array('EMAIL, PASSWORD, PASSWORD_REPEAT', 'required', 'on'=>'create'),
array('EMAIL', 'unique', 'on'=>'create'),
array('PASSWORD', 'compare', 'compareAttribute'=>'PASSWORD_REPEAT', 'on'=>'create'),
Then, in userPersons controller, I am creating a new instance of the users model. Actually, here is a part of my manipulations there:
$users->attributes = $_POST['users'];
$users->USER_ID = $UserID;
$users->PASSWORD_REPEAT = $_POST['users']['PASSWORD_REPEAT'];
$users->TYPE = "2";
$userpersons->attributes = $_POST['userPersons'];
$userpersons->USER_ID = $UserID;
$result1 = $users->validate("create");
$result2 = $userpersons->validate("create");
if($result1 && $result2)
As you see, I implemented your advise in my previous question, why nothing is changed when I use validate and you told me to specify a name after the 'on'=> and then to pass that name as an argument of the validate function.
At present, the validation works after I click the button "Create". I mean that Yii validates properly and requires these fields to have non-zero value and implements the other rules as well, but doesn't show a star, which shows that the fields is mandatory. As I said, it still performs proper validation when I click the Create button, but at the very first start, immediately after you load the form, you are not informed that these fields are required.
Refer to the attachment if you haven't completely understood my post.
I am just looking for your advice whether this is a bug and I have to create a ticket or not.
Number of downloads: 16