Im using CakePHP 2.0
I have a Model for my Users which is very simple:
<?php
App::uses('Model', 'Model');
class User extends AppModel {
public $name = 'User';
public $validate = array(
'username' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A username is required'
)
),
'password' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A password is required'
)
)
);
public function beforeSave(array $options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
}
?>
However I keep getting the following error:
Fatal Error: Class 'String' not found in /home/xxx/app/Model/User.php on line 27.
The error disappears if I comment the beforeSave function.
What am I missing?
Try changing:
public function beforeSave(array $options = array()) {
to
public function beforeSave($options = array()) {