I'm following the first tutorial and I'm having problems with the save() method. Here is the code:
//Store and check for errors
if ($user->save($_POST, array('name', 'email')) == true) {
echo "Thanks for register!";
} else {
echo "Sorry, the following problems were generated: ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
It doesn't work, it always present this error message:
Sorry, the following problems were generated: name is required email is required
But if I set the variables like this it works:
//Store and check for errors
$user->name = $_POST['name'];
$user->email = $_POST['email'];
if ($user->save() == true) {
echo "Thanks for register!";
} else {
echo "Sorry, the following problems were generated: ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
Any idea why this is happening? Is this a bug?