Php表单生成器类隐藏字段

时间:2012-01-15 18:32:18

标签: php mysql forms

我昨天开始使用PFBC,我无法弄清楚如何传递我的URL $ _GET变量,而且我已经阅读了所有可用的文档都无济于事。我在文档中没有看到的另一件事是隐藏字段的示例,因为我尝试传递变量,但无济于事。我可以从var转储中看到GET变量在页面加载时被拾取但我无法在“提交”时接收它们。在我的脚本下面,所有变量都显示正常,除了$ ids。我已经尝试将GET变量放入会话,没有工作....隐藏的字段,没有工作,以及下面列出的方式,不起作用....对于熟悉这个类的人来说它的蛋糕如此一些这里的指导会有所帮助。我使用pfbc2.2-php5,几乎没有旧的文档。我的代码是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Step One: Physician Feedback</title>
<link rel="stylesheet" type="text/css" href="MachForm/data/form_1/css/view.css" media="all" />
</head>
<body id="main_body" >
<img id="top" src="MachForm/images/top.png" alt="" />
<div id="form_container">
  <div id="form_container" style="background-color: #004F79; height:45px;"></div>
  <div style="padding:30px;">
    <div class="form_description">
      <h2>Step One: Physician Feedback</h2>
      <p></p>
    </div>
    <?php
session_start();
error_reporting(E_ALL);
include("PFBC/Form.php");
if (isset($_POST["form"])) {
    if (Form::isValid($_POST["form"])) {
        /*The form's submitted data has been validated.  Your script can now proceed with any 
        further processing required.*/
        $ids       = $_GET["nums"];
        $name      = $_POST['name'];
        $title     = $_POST['title'];
        $dept      = $_POST['dept'];
        $phone     = $_POST['phone'];
        $tech      = $_POST['tech'];
        $latex     = $_POST['latex'];
        $eliminate = $_POST['eliminate'];
        $stock     = $_POST['stock'];
        $urgent    = $_POST['urgent'];
        $reason    = $_POST['reason'];
        $date      = $_POST['date+'];
        echo $ids;
        //header("Location: " . $_SERVER["PHP_SELF"]);
    } else {
        /*Validation errors have been found.  We now need to redirect back to the 
        script where your form exists so the errors can be corrected and the form
        re-submitted.*/
        header("Location: " . $_SERVER["PHP_SELF"]);
    }
    exit();
}
?>
   <?php
$options  = array(
    "Order as needed",
    "Shelf Stock",
    "Consignment"
);
$options1 = array(
    "Urgent",
    "High",
    "Medium",
    "Low"
);
$options2 = array(
    "Lower Cost Item",
    "Needed for new procedure",
    "Reduces Length of Stay",
    "Improves Safety",
    "Reduces Procedure Time"
);
$form     = new Form("anything", 700);
$form->addElement(new Element_Hidden("form", "anything"));
$form->configure(array(
    "view" => new View_Grid(array(
        2,
        2,
        2,
        2,
        1,
        1,
        1
    ))
));
$form->addElement(new Element_Textbox("Name:", "name", array(
    "required" => 1
)));
$form->addElement(new Element_Textbox("Title:", "title", array(
    "required" => 1
)));
$form->addElement(new Element_Textbox("Department:", "dept", array(
    "required" => 1
)));
$form->addElement(new Element_Textbox("Phone:", "phone", array(
    "required" => 1
)));
$form->addElement(new Element_YesNo("Is this new technology:", "tech", array(
    "required" => 1
)));
$form->addElement(new Element_YesNo("Does this product contain latex:", "latex", array(
    "required" => 1
)));
$form->addElement(new Element_YesNo("Is the current technology being eliminated:", "eliminate", array(
    "required" => 1
)));
$form->addElement(new Element_Radio("What is the stocking preference:", "stock", $options, array(
    "inline" => 1,
    "required" => 1
)));
$form->addElement(new Element_Radio("How urgent is this request:", "urgent", $options1, array(
    "inline" => 1,
    "required" => 1
)));
$form->addElement(new Element_Select("Primary Rationale For this request:", "reason", $options2, array(
    "required" => 1
)));
$form->addElement(new Element_Date("Date:", "date+"));
$form->addElement(new Element_Button);
$form->render();
//var_dump(get_defined_vars());
?>
 </div>
</div>
<img id="bottom" src="MachForm/images/bottom.png" alt="" />
</body>
</html>

1 个答案:

答案 0 :(得分:0)

这个课程非常简单。不知道为什么我这么糟糕。只需添加这些行并在背面拾取POST。效果很好。我真的很喜欢这堂课。 $ hide = $ _GET ['nums']; $ form-&gt; addElement(new Element_Hidden(“hidden”,“$ hide”));