I am fairly new to Yii and I have a small problem, but cannot figure it out. The problem is that when i call in Yii in one of my models (active records) $this->attributes = ‘something’; I get error “Property “SiteController.attributes” is not defined.”
I have this in controller:
public function actionIndex()
{
// Create new clients active record
$client = new Clients;
// Check if user send some request
if (isSet($_POST)){
switch($_POST["action"]){
case 'newClient':
$registered = $client::addClient($_POST);
}
}
// render the view
$this->render('landing',array(
// Objects
'client' => $client,
// Variables
'registered' => $registered,
));
return true;
}
and this in the model:
public function addClient($data){
// Set data
$this->attributes = $data["Clients"];
$this->password = self::generatePassword(6);
// Proceed
$this->setScenario('insert');
return true;
}
The functions are not complete of course but this is where i get the error. What is it exactly I’m doing wrong? Thank you
You are calling the function as static method.
$registered = $client::addClient($_POST);should be