Keycode Goes Back To Null Value


I have the following code …

public function actionSetClientLinkStatus($keycode, $status) {


	$status_map = array(


		"accept" => "accepted",

		"pending" => "pending",

		"reject" => "rejected"




	$client_link = ClientLink::model()->findByAttributes(array("keycode" => md5($keycode)));

	$client_link->status = $status_map[$status];			

	if(!$client_link->save()) echo true;



For some reason, it updates the "status" but it keeps setting my "keycode" back to a null value, why is that?

print_r($client_link->attributes) reveals the "keycode" is set correctly.

are you trying to update the keycode as well

Dear Friend

1.Check whether you have set any validation rule for the attribute status .

2.Else you can do the the following.I hope it helps.

$client_link->status = $status_map[$status];