PHP表单生成器类在填写表单之前显示错误

时间:2015-03-03 15:37:21

标签: php forms pfbc

我使用PFBC进行验证,当我最初加载表单并提交时,它没问题。但是,如果我再回到表单并再次尝试,它会在表单加载后立即显示错误(即在我尝试提交任何内容之前)。

session_start();

use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;

include("../../PFBC/Form.php");

if(Form::isValid("webform", true)) {
  print "form ok";
  Form::clearValues("webform");
}
else {
  header("redirecturl.php");
}

$form = new Form("webform");

$form->configure(array(
    "prevent" => array("bootstrap")
));

$form->addElement(new Element\Textbox("Name:", "name", array("required" => 1, "size" => 40)));
$form->addElement(new Element\Email("E-mail:", "email", array("required" => 1, "size" => 40)));
$form->addElement(new Element\Textarea("Problem:", "problem", array("required" => 1, "style" => "width: 400px; height: 200px;")));

$form->addElement(new Element\Button("Submit Form", "submit", array("id" => "submit")));

$form->render();

0 个答案:

没有答案