Hi All,
After spending an hour browing websites trying to find a solution, I am back to phpbuilder..
I have extended the PFBC forms class wo add my own forms. The first is a login form. However, when I run it and I enter the wrong username, the form does not show errors. Is there seomthing I need to do to trigger the errors? Or am I just doing something very silly ? ( 🙁 why is it so hard to learn new methodology 🙁 )
$user is set to always return false, just for testing the forms.
The class extension
namespace PFBC;
class jf_form extends Form
{
function login_form()
{
// $form = new Form("login");
$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();
}
}
My implementation in the script:
use PFBC\jf_form;
use 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();
}
}
else
{
// create login form
$formi->login_form();
}