In Model.php Add this rules
public
function
rules()
{
return
array
(
array
('username, password,confirmpassword,firstname,
lastname, email,address, companyname, usertype,
isactive
', '
required',
'on'
=>
'insert'
),
array
('username, firstname,lastname, email,address,
companyname, usertype,isactive
', '
required',
'on'
=>
'updateuser'
),
array
(
'password,confirmpassword'
,
'required'
,
'on'
=>
'changepassword'
),
array
(
'password'
,
'compare'
,
'compareAttribute'
=>
'confirmpassword'
,
'on'
=>
'insert,changepassword'
),
array
(
'password'
,
'passwordalphanumeric'
,
'on'
=>
'changepassword'
),
array
('username,password,firstname,lastname,
email,address,companyname,phoneno,mobileno',
'filter'
,
'filter'
=>
'trim'
),
}
public
function
passwordalphanumeric(
$attribute_name
,
$params
){
if
(!
empty
(
$this
->password)){
if
(preg_match(
'~^[a-z0-9]*[0-9][a-z0-9]*$~i'
,
$this
->password)) {
}
else
{
$this
->addError(
$attribute_name
,
'Enter password with digits'
);
}
}
}
No comments:
Post a Comment