i had 2 form, register and update form…
in register form, all field was required but in update form field password2 and verifyCode no need…
here is my models rules
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('username', 'required'),
array('password', 'required'),
array('name, email', 'required'),
array('id_country', 'required'),
array('password2', 'required','on'=>'register'),
array('verifyCode', 'required', 'on'=>'register'),
array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd'),'on'=>'register'),
array('wp_total, wp_counter, status', 'numerical', 'integerOnly'=>true),
array('id_admin, id_country', 'length', 'max'=>20),
array('password', 'length', 'max'=>100, 'min'=>3),
array('username', 'length', 'max'=>100, 'min'=>3),
array('ip, notes', 'length', 'max'=>255),
array('name', 'length', 'max'=>160),
array('email','email','checkMX'=>true),
array('password2', 'length', 'max'=>50, 'min'=>5),
array('password', 'compare','compareAttribute'=>'password2', 'on'=>'register'),
array('username, email', 'unique'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id_developer,id_admin, id_country, date_created, date_last_update, username, password, name, notes, wp_total, wp_counter, ip, status', 'safe', 'on'=>'search'),
);
}
with that code, update success but in register i’m be able to save without fill field password2 and verifyCode.
but when i changed
array('password2', 'required','on'=>'register'),
array('verifyCode', 'required', 'on'=>'register'),
to
array('password2', 'required''),
array('verifyCode', 'required'),
register must fill all that field (that’s i want) and in update i can’t save the record because they need field password2 and verifycode…
why it’s because??
how to solve that??
thanks in advance
sorry for my bad english