machuga/php-activerecord-spark — Issue #9: Model::is_valid() function broken?
Author: dlabs88
Created: 2012-01-30 04:06:29+00:00
State: open

Controller:

public function register()
{
if($_POST)
{
$register = User::is_valid(array(
'username' => $_POST['username'],
'password' => $_POST['password']
));

if($register)
{
redirect('users/login');
}
else
{
print_r ($register->errors->full_messages());
}
}
}

Model:

class User extends ActiveRecord\Model
{
var $password = FALSE;

static $validates_size_of = array(
array('username', 'within' => array(3,15)),
array('password', 'minimum' => 6)
);

function before_save()
{
if($this->password)
{
$this->hashed_password = $this->hash_password($this->password);
}
}

private function hash_password($password)
{
$salt = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
$hash = hash('sha256', $salt . $password);

return $salt . $hash;
}

error message:
Fatal error: Call to undefined method Users::_validate() in /home/test/domains/test/public_html/sparks/php-activerecord/0.0.2/vendor/php-activerecord/lib/Model.php on line 1077