我正在致力于PFBC的实施。为此,我写了一个基本上运行登录表单的扩展。当用户无法登录时,我想显示错误消息。据我所知,PFBC应该自动显示,但不知道它不会。
我已经将用户类跳转到始终返回false,并验证我确实到达了实现的正确部分。我希望表格显示错误:无效的电子邮件地址/密码,但我只得到一个空表格。有人可以帮助我让这个工作吗?
这是类扩展
命名空间PFBC;
class jf_form extends Form
{
function login_form()
{
$this->addElement(new Element\HTML('<legend>Login</legend>'));
$this->addElement(new Element\Hidden("form", "login"));
$this->addElement(new Element\Email("Email Address:", "Email", array(
"required" => 1
)));
$this->addElement(new Element\Password("Password:", "Password", array(
"required" => 1
)));
$this->addElement(new Element\Checkbox("", "Remember", array(
"1" => "Remember me"
)));
$this->addElement(new Element\Button("Login"));
$this->addElement(new Element\Button("Cancel", "button", array(
"onclick" => "history.go(-1);"
)));
$this->render();
}
}
并实施: 使用PFBC \ jf_form; 使用PFBC \ Element;
// Initiate forms
$formi = new PFBC\jf_form();
// Test login
if(jf_form::isValid("login", false))
{
// form was submitted
$user = new user();
if($user->login($_POST["Email"], $_POST["Password"]))
{
jf_form::clearValues("login");
}
else
{
jf_form::setError("login", "Error: Invalid Email Address / Password");
$formi->login_form();
echo "false";
}
}
else
{
// create login form
$formi->login_form();
}
答案 0 :(得分:0)
$formi = new PFBC\jf_form("jflogin");
if(jf_form::isValid("jflogin", false))
{