I am using symfony 1.0.6 and in action file we can set error using,
$this->getRequest()->setError("email", "The email address does not look valid. Please re-check the address.");
But when used at /lib/model/User.php, with a static function
public static function createNewUser() {
if(preg_match("/\bUsername\b/i", $err)) {
$sf_request->setError('rusername', "Username already taken. Please choose a different one");
}
if(preg_match("/\bemail\b/i", $err)) {
$sf_request->setError('Email', "This email address is already registered. Please use another");
}
}
It is resulting in an error: “Undefined variable: sfRequest”.
How to set error in static method using sfrequest instance ?
Can sfRequest instance be created whilst it is abstract class…?
1.06 is very old, and no longer officially supported. I would recommend that you consider upgrading to 1.4.x, or if you aren’t too deep into the project, look into symfony2. Not sure about 1.06 but in 1.4.x you can do this: